Sunan an-Nasa'i, Volume 3, Book 22, Hadith 2140 (DarusSalam)

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."'

أَخْبَرَنَا أَبُو دَاوُدَ، قَالَ حَدَّثَنَا هَارُونُ، قَالَ حَدَّثَنَا عَلِيٌّ، - هُوَ ابْنُ الْمُبَارَكِ - قَالَ حَدَّثَنَا يَحْيَى، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ الشَّهْرُ يَكُونُ تِسْعَةً وَعِشْرِينَ وَيَكُونُ ثَلاَثِينَ فَإِذَا رَأَيْتُمُوهُ فَصُومُوا وَإِذَا رَأَيْتُمُوهُ فَأَفْطِرُوا فَإِنْ غُمَّ عَلَيْكُمْ فَأَكْمِلُوا الْعِدَّةَ ‏" ‏ ‏.‏

sunnah.com