If someone makes the intention before the time of ṣubḥ prayers to fast the next day, goes to sleep, and wakes up after maghrib, his fast is valid.