A man came to the Prophet ﷺ and asked, "Messenger of Allah, how do you fast?"The Messenger of Allah ﷺ became angry at his question. When Umar saw this, he said, "We are pleased with Allah as our Lord, with Islam as our religion, and with Muhammad as our Prophet. We seek refuge in Allah from the anger of Allah and from the anger of His Messenger." Umar kept repeating this until the anger of the Messenger of Allah ﷺ subsided.Then the man asked, "Messenger of Allah, what about one who fasts every single day?"He replied, "He has neither fasted nor broken his fast." Musaddad said, "He did not fast and did not break his fast," or "He has not fasted nor broken his fast." Ghaylan was uncertain about the wording.The man asked, "Messenger of Allah, what about one who fasts two days and breaks his fast for one?"He replied, "Is anyone able to do that?"The man asked, "Messenger of Allah, what about one who fasts a day and breaks his fast a day?"He replied, "That is the fast of Dawud."The man asked, "Messenger of Allah, what about one who fasts a day and breaks his fast for two?"He replied, "I wish I were granted the strength to do that."Then the Messenger of Allah ﷺ said, "Three days of every month, and Ramadan to Ramadan, this is fasting all the time. As for fasting the day of Arafah, I hope from Allah that it expiates the year before it and the year after it. And as for fasting the day of Ashura, I hope from Allah that it expiates the year before it."
حدثنا سليمان بن حرب ومسدد قالا حدثنا حماد بن زيد عن غيلان بن جرير عن عبد الله بن معبد الزماني
أن رجلا أتى النبي ﷺ فقال يا رسول الله كيف تصوم فغضب رسول الله ﷺ من قوله فلما رأى ذلك عمر قال رضينا بالله ربا وبالإسلام دينا وبمحمد نبيا نعوذ بالله من غضب الله ومن غضب رسوله فلم يزل عمر يرددها حتى سكن غضب رسول الله ﷺ فقال يا رسول الله كيف بمن يصوم الدهر كله قال لا صام ولا أفطر قال مسدد لم يصم ولم يفطر أو ما صام ولا أفطر شك غيلان قال يا رسول الله كيف بمن يصوم يومين ويفطر يوما قال أو يطيق ذلك أحد قال يا رسول الله فكيف بمن يصوم يوما ويفطر يوما قال ذلك صوم داود قال يا رسول الله فكيف بمن يصوم يوما ويفطر يومين قال وددت أني طوقت ذلك ثم قال رسول الله ﷺ ثلاث من كل شهر ورمضان إلى رمضان فهذا صيام الدهر كله وصيام عرفة إني أحتسب على الله أن يكفر السنة التي قبله والسنة التي بعده وصوم يوم عاشوراء إني أحتسب على الله أن يكفر السنة التي قبله
This was collected by Muslim in the Book of Fasting, Chapter on the recommendation of fasting three days from each month: hadith 1162, from the hadith of Ghaylan bin Jareer, and so on.