REGALIM CANCEL SHELOSHIM
Gemara
(Mishnah): If burial was eight days before the Regel, the Regel cancels Sheloshim (the restrictions of the first 30 days). This is because Shabbos counts towards the days of Avelus but does not interrupt, and Regalim interrupt but do not count.
R. Eliezer says, after the Churban, Shavu'os is like Shabbos;
R. Gamliel says, Rosh Hashanah and Yom Kipur are like Regalim.
Chachamim say, Shavu'os is like Regalim, and Rosh Hashanah and Yom Kipur are like Shabbos.
(Gemara - Beraisa): If burial was eight days before the Regel, the Regel cancels Sheloshim, and he may shave on Erev Yom Tov. If he did not, he may not shave after the Regel;
Aba Sha'ul says, (in any case) he may shave after the Regel. Just like three days (before the Regel) cancels Shivah, also seven days cancels Sheloshim.
Question: Our Mishnah requires eight days to cancel Sheloshim!
Answer: Aba Sha'ul holds that Miktzas ha'Yom k'Kulo (part of a day counts like an entire day), and the seventh day counts for both (it completes Shivah, and it also begins the rest of Sheloshim).
(Rav Chisda and Abaye): The Halachah follows Aba Sha'ul.
(Rava): The Halachah does not follow Aba Sha'ul.
(Chachamim of Neharda'a): The Halachah follows him, for Shmuel taught that the Halachah follows the lenient opinion in Aveilus.
24a (Rav Gidal citing Shmuel): The Halachah follows R. Gamliel (Rosh Hashanah and Yom Kipur are like Regalim).
(Rav Anani bar Sason and R. Yitzchak Nafcha): (If one was an Avel) one day before Shavu'os, with Shavu'os it is considered 14 days. (Even one day or one moment before the Regel suffices, and Shavu'os is considered a Regel.)
R. Ami and Rav Sheshes: This Chidush is due to R. Elazar in the name of R. Oshaya (who expounded that there are seven days of Tashlumim for Shavu'os, just like for Pesach).
(Rav Papa): (Aveilus) one day before Rosh Hashanah with Rosh Hashanah are considered 14 days.
(Ravina): Therefore, one day before Sukos, with eight days of Sukos, is considered 21 days.
Rav Chaviva (to Ravina): Did you say that one day before Rosh Hashanah with Rosh Hashanah is considered 14 days?
Ravina: I said that presumably, the Halachah follows R. Gamliel (who considers Rosh Hashanah like Regalim).
Rishonim
Rif and Rosh (3:26): The Halachah follows Aba Sha'ul, who counts the seventh day to complete Shivah and also towards Sheloshim. Just like one day, or one moment before the Regel cancels Shivah (20a), also one day or one moment (of Sheloshim) before the Regel cancels Sheloshim.
Nimukei Yosef (DH Masnisin): R. Eliezer holds that Shavu'os is like a Regel only when the Mikdash stands, for then the seven days of Tashlumim apply. R. Gamliel says that Rosh Hashanah and Yom Kipur are like Regalim, even though no Tashlumim ever applies to them. All the more so Shavu'os is like a Regel even nowadays.
Kesef Mishneh (Hilchos Evel 10:3): The Ramban says that Rosh Hashanah and Yom Kipur are like Regalim even though they have no Tashlumim, because "Eleh Mo'adei Hash-m" equates all the Mo'adim.
Rif and Rosh (3:28): We hold that Shavu'os is like Regalim. This follows from Rav Anani (and R. Ami...) The Halachah follows R. Gamliel, who says that Rosh Hashanah and Yom Kipur are like Regalim.
Question (Ra'avad, brought in Rosh 3:28): Why does Rav Papa teach that one day before Rosh Hashanah with Rosh Hashanah are 14 days? He holds that also Yom Kipur is a Regel, so in any case Yom Kipur cancels Sheloshim!
Answer #1 (Ra'avad): Since we were lenient to say that Rosh Hashanah cancels Shivah, we do not apply another leniency to say that Yom Kipur cancels Sheloshim. Yom Kipur does not even count like seven days. The Sheloshim do not end until Sukos, the primary Regel.
Rosh (ibid.): BaHaG agrees that Yom Kipur does not cancel Sheloshim, but he says that it counts like seven days, so Sheloshim ends two days after Yom Kipur. The Ba'al ha'Ma'or says that this is unreasonable. Yom Kipur cancels Sheloshim for one who buried his Mes after Rosh Hashanah, for then Shivah finishes on Erev Yom Kipur. How can Yom Kipur not cancel Sheloshim for one who buried his Mes earlier, before Rosh Hashanah, and observed seven days towards Sheloshim?! The Ra'avad already answered this. Since a full Shivah was not observed, we are not lenient to interrupt Sheloshim.
Answer #2 (Rosh citing Ramban): Rav Anani taught that one day before Shavu'os, with Shavu'os, is considered 14 days. Rav Papa said the same about Rosh Hashanah for parallel structure, even though it would have sufficed to teach that Rosh Hashanah cancels Shivah. This is a better answer. We should not build edifices of flimsy reasoning and derive new laws with no basis other than an answer to a question.
Answer #3 (Rosh citing R. Shimshon): We learned that an Avel does not leave his house the first week, the second week he does not sit in his place,... Rav Papa teaches that after Rosh Hashanah, it is as if two weeks have passed.
Conclusion (Rosh): Yom Kipur cancels Sheloshim even when Rosh Hashanah cancelled Shivah. However, Shemini Atzeres does not cancel Sheloshim when Sukos cancelled Shivah, for then he never observed Sheloshim.
Ramban (brought in Beis Yosef YD 399 DH u'Mah she'Chosav Ela): Abaye said that surely Mo'ed does not count towards Shivah, since laws of Shivah do not apply. He asked about Sheloshim, because some laws of Sheloshim apply. Also some laws of Shivah apply, e.g. he may not wash his garment even in water! We must say that all laws of Sheloshim apply, i.e. laundering and shaving, even when they are not forbidden due to the Regel. They are all Isurim, and most of them normally apply because of the Regel anyway, so his observance of Sheloshim is not evident. Therefore, Shemini Atzeres does not cancel Sheloshim.
Rambam (Hilchos Evel 10:3): If one buried his Mes even a moment before a Regel, Rosh Hashanah or Yom Kipur, Shivah is cancelled. Therefore, after Rosh Hashanah or Yom Kipur he counts 23 days.
Rebuttal (Ra'avad): This is wrong. Rosh Hashanah is a Regel, so it cancels seven days in addition to Shivah.
Answer (Kesef Mishneh): The Rambam agrees with the Ra'avad (brought above, in the Rosh) that when a full Shivah was not observed, we do not cancel Sheloshim. He rules like Ravina. Ravina was asked if one day before Rosh Hashanah with Rosh Hashanah is like 14 days. He answered 'I said (only) that presumably, the Halachah follows R. Gamliel' (Rosh Hashanah is like a Regel to be Mafsik, but it does not count like 14 days). The Ramban disagrees. Ravina counts Shemini Atzeres like seven days, even though there is no Tashlumim for it, because a Hekesh equates all the Mo'adim. The same applies to Rosh Hashanah and Yom Kipur.
Rambam (ibid.): After Pesach he counts 16 days, for Shivah was cancelled and the seven days of Pesach (deduct from the remaining 23). Likewise, if one buried his Mes before Shavu'os he counts 16 days afterwards. Even though Shavu'os is only one day, it is a Regel and counts like seven days.
Rambam (4): If one buried his Mes before Sukos he counts nine days afterwards. Shemini Atzeres is a Regel unto itself. The first Yom Tov cancels Shivah, there are seven days of the Chag, and Shemini Atzeres cancels seven days, making 21.
Rambam (5): If one buried his Mes seven days before any Regel, this cancels Sheloshim. He does not count anything afterwards. If a parent died even 30 days before the Regel, he may not shave until his hair is very long or his friends rebuke him (for his long hair).
Rosh (3:42): If one's parent died he may not shave until his friends rebuke him, even if a Regel passes more than 30 days later.
Poskim
Shulchan Aruch (YD 399:3 and OC 548:8): If one buried his Mes seven days before a Regel and observed laws of Sheloshim, the Regel cancels Sheloshim. This is even if the seventh day was Erev ha'Regel, for Miktzas ha'Yom k'Kulo. The day counts for Shivah and Sheloshim. He may bathe, launder and cut his hair on Erev ha'Regel.
Rema (YD): This is permitted close to dark. On Erev Pesach everything is permitted after midday, the time of Shechitas Korban Pesach. It is better to shave before midday, since others forbid shaving after midday.
Question (Shach 11): This is learned from Mahari Mintz (4). But he permits only shaving early, since some forbid after midday, but regarding bathing and laundering it is like any other Erev ha'Regel!
Beis Yosef (DH Kasuv b'Tashbatz): The Tashbatz says that since Erev Pesach is Zman Shechitas Pesach and they used to say Hallel, Aveilus does not apply then. There is no source for this.
Darchei Moshe (4): The Or Zaru'a agrees that Aveilus does not apply on Erev Pesach from the time of Shechitah. One may rely on this.
Gra (9): The Torah (Vayikra 23:4,5) and Gemara (Pesachim 55b and Moed Katan 13a) call Erev Pesach 'Mo'ed'.
Rema (OC): The same applies to bathing for us, for we forbid bathing all 30 days. One may bathe close to dark; he need not wait for night.
Shulchan Aruch (ibid.): Also (or all the more so) if the eighth day was Shabbos and Erev ha'Regel, one may launder, bathe and cut hair on Erev Shabbos. If he did not shave before the Regel, it is permitted after the Regel, because Sheloshim was cancelled. If the seventh day was Shabbos and Erev ha'Regel, one may not shave on Erev Shabbos, but it is permitted after the Regel.
Bi'ur Halachah (DH she'Mutar): When day seven is Erev ha'Regel we must wait until close to dark, so it will be evident that he bathes, launders and shaves for Kavod ha'Regel. This does not apply on Erev Shabbos that is Erev ha'Regel, so these are permitted before Minchah.
Shulchan Aruch (YD 4 and OC 9): The Regel does not cancel Sheloshim observed for a parent, since the Isur to shave extends until his friends rebuke him.
Kaf ha'Chayim (48): The Regel cancels Sheloshim for a parent regarding laundering and bathing.
Shulchan Aruch (YD 9 and OC 14): If one buried his Mes a moment before Rosh Hashanah, Shivah is cancelled. Yom Kipur cancels Sheloshim, so he may shave on Erev Yom Kipur.
Mishnah Berurah (44): In this case one need not wait for close to dark, because seven days have passed.
Shulchan Aruch (YD 11 and OC 16): If one buried his Mes a moment before Sukos, Shivah is cancelled. After Shemini Atzeres he must observe eight days of Sheloshim.