It used to be that if any one of them fell asleep before having his evening meal, it was not lawful for him to eat or drink anything that night, the following day, or until the sun set, until this verse was revealed: "And eat and drink until the white thread becomes distinct to you from the black thread" [Baqarah 2:187].He said, "It was revealed concerning Ubayy Qays bin Amr, who came to his family while fasting after sunset and asked, 'Is there anything to eat?'His wife replied, 'We have nothing here, but let me go out and find you something for the evening meal.'She went out, and meanwhile he laid down his head and fell asleep. When she returned, she found him sleeping and woke him, but he ate nothing. He spent the night without food and woke up still fasting until midday, when he fainted. This happened before this verse was revealed, so Allah revealed it concerning him."
أخبرني هلال بن العلاء بن هلال قال حدثنا حسين بن عياش قال حدثنا زهير قال حدثنا أبو إسحق
أن أحدهم كان إذا نام قبل أن يتعشى لم يحل له أن يأكل شيئا ولا يشرب ليلته ويومه من الغد حتى تغرب الشمس حتى نزلت هذه الآية {وكلوا واشربوا إلى الخيط الأسود} قال ونزلت في أبي قيس بن عمرو أتى أهله وهو صائم بعد المغرب فقال هل من شيء فقالت امرأته ما عندنا شيء ولكن أخرج ألتمس لك عشاء فخرجت ووضع رأسه فنام فرجعت إليه فوجدته نائما وأيقظته فلم يطعم شيئا وبات وأصبح صائما حتى انتصف النهار فغشي عليه وذلك قبل أن تنزل هذه الآية فأنزل الله فيه
Bukhari recorded it in the Book of Fasting, chapter on Allah's saying, "It has been made permissible for you on the night of fasting to approach your wives..." etc, hadith no. 1915, from the hadith of Abu Ishaq, using the same wording, and he stated explicitly that he heard it directly, hadith no. 4508, and it is also in Al-Kubra, hadith no. 278.Zuhayr is Ibn Muawiya.