Sayyiduna Abu Hurayrah (may Allah be pleased with him) said that Abu al-Qasim (peace and blessings be upon him) said: "Fast upon sighting it (the crescent) and break the fast upon its appearing. If in that month it is clouded over you, then count thirty days, that is, thirty days of Sha'ban." Imam al-Bukhari (may Allah have mercy on him) said: If it is cloudy, then complete thirty days of Sha'ban.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصيام / 7932