Sunan an-Nasa'i, Hadith 2138 ⓘ
It was narrated that Abu Hurairah said: "The Messenger of Allah said: The month may be twenty-nine days or it may be thirty. When you see it, then stop fasting, and it is obscured from you (too cloudy), then complete the count."'
أَخْبَرَنَا أَبُو دَاوُدَ، قَالَ حَدَّثَنَا هَارُونُ، قَالَ حَدَّثَنَا عَلِيٌّ، - هُوَ ابْنُ الْمُبَارَكِ - قَالَ حَدَّثَنَا يَحْيَى، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " الشَّهْرُ يَكُونُ تِسْعَةً وَعِشْرِينَ وَيَكُونُ ثَلاَثِينَ فَإِذَا رَأَيْتُمُوهُ فَصُومُوا وَإِذَا رَأَيْتُمُوهُ فَأَفْطِرُوا فَإِنْ غُمَّ عَلَيْكُمْ فَأَكْمِلُوا الْعِدَّةَ " .
also referenced under: Book 22, Hadith 49 (In-Book) & Volume 3, Book 22, Hadith 2140 (DarusSalam)