Sunan an-Nasa'i, Book 22, Hadith 28 (Nasa'i 2122)

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