The verse was revealed, "Eat and drink until the white thread becomes distinct to you from the black thread" [Baqarah 2:187], and the words "of dawn" had not yet been revealed. So when men intended to fast, one of them would tie a white thread and a black thread to his leg, and he would keep eating until he could clearly see the two of them. Then Allah revealed afterward the words "of dawn" [Baqarah 2:187], and they understood that what was meant was night and day.
أنزلت: {وكلوا واشربوا حتى يتبين لكم الخيط الأبيض من الخيط الأسود} ولم ينزل: {من الفجر} فكان رجال إذا أرادوا الصوم ربط أحدهم في رجله الخيط الأبيض والخيط الأسود، ولم يزل يأكل حتى يتبين له رؤيتهما، فأنزل الله بعد: {من الفجر} فعلموا أنه إنما يعني الليل والنهار.
Bukhari reported it in the Book of Fasting (1917) and Muslim in the Book of Fasting (35:1019), both from the hadith of Saeed bin Abu Maryam, who said, Abu Ghassan informed us, Abu Hazim narrated to me, from Sahl bin Saad, who said, and then he mentioned it, with both wordings being the same.