Sahih al-Bukhari 378
Anas ibn Mālik (r.a) narrated: ‘The Messenger of Allāh (saw) once fell from his horse, injuring either his leg or his shoulder. He took a vow to stay away from his wives for a month, so he secluded himself in the upper chamber [in his house], which had stairs made from date-tree trunks. His Companions came to visit him and he led them seated in Prayer, while they stood. At the conclusion of the Prayer [with taslīm], he said: “The imām has been appointed to be followed. So when he says, ‘Allāhu Akbar’, you should say, ‘Allāhu Akbar’, and when he does rukūʿ, you should do rukūʿ, and when he goes into sujūd, you should do sujūd, and if he prays standing up, you should pray standing up.” He came down [from the upper chamber] after 29 [nights] and people said: “O Messenger of Allāh, you vowed to stay away [from your wives] for a month [i.e. 30 days].” He said: “A month also consists of 29 days”.’
Translation: Ahmadiyya Muslim Jamaat
Book 18: (It is permissible) to offer Salat (prayer) on roofs, a pulpit or wood