In the lifetime of Messenger of Allah ﷺ the sun eclipsed, so he led the people in prayer, and stood up and performed a long Qiyam, then bowed for a long while. He stood up again and performed a long Qiyam but this time the period of standing was shorter than the first. He bowed again for a long time but shorter than the first one, then he prostrated and prolonged the prostration. He did the same in the second rakʿa as he did in the first and then finished the prayer; by then the sun (eclipse) had cleared. He delivered the Khutba (sermon) and after praising and glorifying Allah he said, "The sun and the moon are two signs against the signs of Allah; they do not eclipse on the death or life of anyone. So when you see the eclipse, remember Allah and say Takbir, pray and give Sadaqa." The Prophet then said, "O followers of Muhammad! By Allah! There is none who has more ghaira (selfrespect) than Allah as He has forbidden that His slaves, male or female commit adultery (illegal sexual intercourse). O followers of Muhammad! By Allah! If you knew that which I know you would laugh little and weep much. (Using translation from Bukhārī 1044)
خَسَفَتِ الشَّمْسُ فِي عَهْدِ رَسُولِ اللهِ ﷺ فَصَلَّى رَسُولُ اللهِ ﷺ بِالنَّاسِ فَقَامَ فَأَطَالَ الْقِيَامَ ثُمَّ رَكَعَ فَأَطَالَ الرُّكُوعَ ثُمَّ قَامَ فَأَطَالَ الْقِيَامَ وَهُوَ دُونَ الْقِيَامِ الْأَوَّلِ ثُمَّ رَكَعَ فَأَطَالَ الرُّكُوعَ وَهُوَ دُونَ الرُّكُوعِ الْأَوَّلِ ثُمَّ رَفَعَ فَسَجَدَ ثُمَّ فَعَلَ فِي الرَّكْعَةِ الْأُخْرَى مِثْلَ ذَلِكَ ثُمَّ انْصَرَفَ وَقَدْ تَجَلَّتِ الشَّمْسُ فَخَطَبَ النَّاسَ فَحَمِدَ اللهَ وَأَثْنَى عَلَيْهِ ثُمَّ قَالَ إِنَّ الشَّمْسَ وَالْقَمَرَ لَا يَخْسِفَانِ لِمَوْتِ أَحَدٍ وَلَا لِحَيَاتِهِ فَإِذَا رَأَيْتُمْ ذَلِكَ فَادْعُوا اللهَ وَكَبِّرُوا وَتَصَدَّقُوا ثُمَّ قَالَ يَا أُمَّةَ مُحَمَّدٍ وَاللهِ مَا مِنْ أَحَدٍ أَغْيَرَ مِنَ اللهِ أَنْ يَزْنِيَ عَبْدُهُ أَوْ تَزْنِيَ أَمَتُهُ يَا أُمَّةَ مُحَمَّدٍ لَوْ تَعْلَمُونَ مَا أَعْلَمُ لَضَحِكْتُمْ قَلِيلًا وَلَبَكَيْتُمْ كَثِيرًا