In the name of Allah,
Firstly,
When a person eats, drinks, or has sexual relations thinking it’s still night and then realizes it’s morning. A group of Salaf and Ibn Taymiyyah and Ibn `Uthaymin say his fast is legitimate and does not need to be made up. The four schools of law agree he must make it up.
Secondly,
Scholars disagree on whether a person who broke his fast thinking the sun had set should make it up.
First: He has to make up the fast. The four legal schools concur.
The Malikis say that if one has doubts about the sunset, one should not eat, and if one does, one must make up and pay kaffarah. Another claim is that all one needs to do is make up [I]. The Hanafi classical book Mukhtaṣar al-Qudūrī stated:
Whoever wakes up for the pre-dawn meal thinking that fajr hasn’t begun yet or breaks his fast thinking that the sun has set, but then realizes that it hasn’t, should do one fast as qad’a for that day, but he doesn’t have to pay kaffarah[ii].
The first group says that because it’s still daylight, a certain fact cannot be replaced by a doubtful one.
The second: He doesn’t have to make it up.
This is the choice of Ibn Taymiyyah, Ibn al-Qayyim, and Ibn ‘Uthaymin, as well as a group of Salaf including Mujaahid, al-Hasan among the Taabi’een, al-Muzani among the Shaafa’is (may Allah have mercy on them).
Shaykh al-Islam Ibn Taymiyah said[iii]:
Our evidence is stronger, and the Qur’an and Sunnah support our claim that the fast is not interrupted if a person forgets or makes a mistake at the start or end of the day.
Allah says:
“Our Lord! Punish us not if we forget or fall into error” [al-Baqarah 2:286]
Forgetting and making mistakes are linked because someone who accidentally performs something unlawful in Hajj or prayer is like someone who does it out of forgetfulness.
One day during the Prophet’s (peace and blessings of Allah be upon him) time, they broke the fast and the sun appeared, but they were not told to make up the fast.
Hishaam ibn ‘Urwah remarked, “It must be made up,” but his father was wiser and responded, “They don’t have to.”
Al-Saheehayn showed that a group of Sahaabah ate until one of them could differentiate the white thread from the black. The Prophet (peace and blessings of Allaah be upon him) said to one of them, “Your pillow is broad [if the white thread (of dawn) and the black thread (of the night) are underneath your pillow], rather that is the whiteness of the day and the darkness of the night.”[iv]
They were unaware of the ruling, therefore he did not tell them to make up their fasts.
‘Umar ibn al-Khattaab broke his fast after realizing it was still day, but he remarked, “We will not make it up because we did not knowingly sin.”
This opinion is stronger in evidence, logic, and Qur’an and Sunnah proof and analogies (qiyas)[v].
May Allah’s peace and blessings be on the last prophet.
Sources:
[i] Al-Qawanin al-Fiqhiyyah: The Judgments of Fiqh, Abu’l-Qasim Ibn Juzayy Al-Kalbi (Author), Asadullah Yate (Translator), Vol 1, page 221
[ii] The MUKHTAṢAR AL-QUDŪRĪ, A Manual of Islamic law, According to the Hanafi School, Page 133
[iv] Sahih al-Bukhari 4509
[v] Majmoo’al-Fataawa, 20/572, 573, See also al-Sharh al-Mumti’, 6/411.