It was narrated that Abu Hurairah said:"the Messenger of Allah said: 'Fast when you see it and stop fasting when you see it, and if it is obscured from you (too cloudy), then count it as thirty (days). "'
أَخْبَرَنَا مُؤَمَّلُ بْنُ هِشَامٍ، عَنْ إِسْمَاعِيلَ، عَنْ شُعْبَةَ، عَنْ مُحَمَّدِ بْنِ زِيَادٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " صُومُوا لِرُؤْيَتِهِ وَأَفْطِرُوا لِرُؤْيَتِهِ فَإِنْ غُمَّ عَلَيْكُمُ الشَّهْرُ فَعُدُّوا ثَلاَثِينَ " .
Nesai
The Book of Fasting • Hadith 2117