كتاب الصيام
13
The Book of Fasting
(32)
Chapter: It is permissible to observe a voluntary fast with an intention formed during the day before the sun reaches its Zenith, and it is permissible for one who is observing a voluntary fast to break his fast with no excuse, although it is better for him to complete it
(32)
بَاب جَوَازِ صَوْمِ النَّافِلَةِ بِنِيَّةٍ مِنْ النَّهَارِ قَبْلَ الزَّوَالِ وَجَوَازِ فِطْرِ الصَّائِمِ نَفْلًا مِنْ غَيْرِ عُذْرٍ

'A'isha, the Mother of the Believers (Allah be pleased with her), reported:

The Apostle of Allah (ﷺ) came to me one day and said: Is there anything with you (to eat)? I said: No. Thereupon he said: I shall then be fasting. Then he came to us another day and we said: Messenger of Allah, hais has been offered to us as a gift. Thereupon he said: Show that to me; I had been fasting since morning. He then ate it.
وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا وَكِيعٌ، عَنْ طَلْحَةَ بْنِ يَحْيَى، عَنْ عَمَّتِهِ، عَائِشَةَ بِنْتِ طَلْحَةَ عَنْ عَائِشَةَ أُمِّ الْمُؤْمِنِينَ، قَالَتْ دَخَلَ عَلَىَّ النَّبِيُّ صلى الله عليه وسلم ذَاتَ يَوْمٍ فَقَالَ ‏"‏ هَلْ عِنْدَكُمْ شَىْءٌ ‏"‏ ‏.‏ فَقُلْنَا لاَ ‏.‏ قَالَ ‏"‏ فَإِنِّي إِذًا صَائِمٌ ‏"‏ ‏.‏ ثُمَّ أَتَانَا يَوْمًا آخَرَ فَقُلْنَا يَا رَسُولَ اللَّهِ أُهْدِيَ لَنَا حَيْسٌ ‏.‏ فَقَالَ ‏"‏ أَرِينِيهِ فَلَقَدْ أَصْبَحْتُ صَائِمًا ‏"‏ ‏.‏ فَأَكَلَ ‏.‏
Reference : Sahih Muslim 1154 b
In-book reference : Book 13, Hadith 221
USC-MSA web (English) reference : Book 6, Hadith 2574
  (deprecated numbering scheme)