Knowing that the time of worship has started is a prerequisite for the validity of the acts of worship. This is the basic rule. However, sometimes a person is locked up in a place where he cannot distinguish day from night. A Muslim who happens to be in this situation still has to perform the obligatory acts of worship as far as he can. He has to exert some kind of ijtihad (personal reasoning) according to the means available to him.
On this topic, Sheikh Muhammad Saleh Al-Munajjid, a well-known Saudi scholar and author, said:
Firstly, we ask Allah to grant all Muslim prisoners a rapid release, to grant them patience and consolation out of His bounty, to fill their hearts with peace and certainty of faith, and to make easy for the Muslims a way of guidance whereby His close friends will be honored and His enemies will be humiliated.
Secondly, the scholars have determined that Prayer and Fasting are not waived for prisoners and detainees. They have to try their best to work out the right times. If a prisoner is almost certain that the time for Prayer has come, he should observe the pray, and if he is almost certain that Ramadan has come, he should fast. He can work out the times by noting the times when food is served to him, or by asking the guards and so on.
If he tries to work out the right time for praying and fasting, his worship will be valid and acceptable, whether he finds out later on that he did it at the right time, or after it, or he does not find out anything, because Allah says, (Allah burdens not a person beyond his scope)(Al-Baqarah 2:286).
(Allah puts no burden on any person beyond what He has given him) (Al-Talaq 65:7)
However, if he finds out that he fasted on the days of Eid, he should make them up, because fasting on the days of `Eid is not valid.
If he finds out later on that he prayed or fasted before the proper time, then he has to repeat the fast or Prayer.
In Al-Mawsoo’ah Al-Fiqhiyyah (28:84-85), it is said:
The majority of fuqaha’ (Muslim jurists) are of the view that if the months all seem to be the same to a person, the fasting of Ramadan is not waived in his case, rather it is still obligatory because he remains accountable and the ruling still applies to him.
If he tries to work it out and fasts, one of the following five scenarios must apply to him:
1 – The problem continues and he cannot find out, so he does not know whether he managed to fast in Ramadan or before it or after it. In this case his fast is valid and he does not have to repeat it, because he did his best, and he is not required to do anything more.
2 – The fast of the prisoner coincided with Ramadan, so it is considered valid.
3 – If his fast happened to be after Ramadan, that is also considered valid according to the majority of fuqaha’.
4 –With the fourth scenario there are two possibilities:
(i) If he started fasting before Ramadan, and he finds out about that before Ramadan comes, then he must fast when Ramadan comes, and there is no difference of opinion among the scholars concerning that.
(ii) If he started fasting before Ramadan and he did not find out about that until Ramadan had finished, there are two opinions as to whether this is acceptable or not:
(a) It is not acceptable for Ramadan, rather he has to make it up. This is the view of the Malikis and Hanbalis.
(b) It is acceptable for Ramadan, just as if the pilgrims are uncertain of the day of `Arafah and they observe the standing before the day. This is the view of some of the Shafi`is.
5 – If the fast of the prisoner coincides with one part of Ramadan and not with the other; that which coincides with Ramadan or comes after it is acceptable, and that which comes before it is not acceptable.
See Al-Majmoo`(3:72-73) and a–Mughni (3:96)
and Allah knows best.