ר"א אומר משחרב בית המקדש עצרת כשבת בו': הלכה כחכמים באמרם עצרת כרגלים וכרבן גמליאל באמרו ראש השנה ויום הכפורים כרגלים. וכשקובר האדם מתו אפילו שעה אחת קודם חג המצות בטלה ממנו גזירת שבעה ושבעה ימי החג נחשבין ויחשב אחר הרגל ששה עשר יום להשלים שלשים יום. וכן אם קבר מתו אפילו שעה אחת קודם עצרת או לפני יום הכפורים וראש השנה יחשוב אחריהן ששה עשר יום לפי שהן כרגלים. ולפיכך כשנקבר לפניהם שבעה ימים בטלה ממנו גזירת שלשים. אבל מי שקבר מתו אפילו שעה אחת קודם חג הסוכות בטלה ממנו גזירת שבעה כדין כל רגל ושבעת ימי החג ושמיני של חג יעלו לו למנין שבעה ימים אחרים כי העיקר אצלינו שמיני של חג רגל בפני עצמו ולא ישארו אחר שמיני של חג אלא תשעה ימים מכל השלשים יום. והקובר את מתו ברגל אינו חייב באבלות עד יום האחרון של חג ר"ל יום טוב שני של שמיני עצרת ויתחיל למנות ממנו ואחר כך ששה ימים ויתחייב באותן הששה גזרת שבעה ואח"כ ימנה שלשים יום מיום שמת בו המת ויתחייב בשאר הדברים אחר המועד בגזירת שלשים. וגזירת שבעה היא מה שאגיד לך והוא. כי כל שבעה ימים חייב בכפיית המטה והוא שלא יהיה בביתו מטה אלא כפויה. ואסור בתשמיש המטה. ובנעילת הסנדל. ובעשיית מלאכה בגלוי. ובשאלת שלום. וברחיצה בחמין אפי' מקצת גופו וברחיצת כל גופו בצונן. ואסור בסיכה. ולקרות בתורה ובמשנה וגמרא. וחייב בעטיפת הראש רוצה לומר שיכסה ראשו ויעטה על שפם. ואסיר לשלול את הקרע. ואסור ליטול צפרניו בכלי וליטול שפמו ואפי' מעכב עליו בשעת האכילה. ואינו רשאי לכבס בגדיו. כל אלו הדברים הם חובה על האבל כל שבעה. ומה שאתה צריך לדעת כי יום ראשון אסור לו להניח תפילין ולאכול קדשים כמו שבארנו בפסחים. וחייב לישב על המטה כפויה על הארץ. ואינו אוכל משלו. ושלשה ימים הראשונים אסור בעשיית מלאכה ואפי' בסתר. ואם נותנין לו שלום אינו מחזיר אלא שיאמר להם אבל הוא. וגזירת שלשים ששה דברים והם. שלא יגלח שערו. ולא ילבש בגד לבן חדש מגוהץ ומוחלק. ואינו מאחה הקרע שקרע על המת. ואינו הולך בסחורה. וכן אמרי' בירושלמי על כל המתים אסור ללכת בסחורה עד שלשים יום. על אביו ועל אמו עד שיגערו בו חביריו ויאמרו לו לך עמנו. אסור לו לשתות במשתה מרעות כל שלשים יום. על אביו ועל אמו שנים עשר חדש. ואסור לישא אשה שניה ולשמש מטתו עמה והוא אמרם כל שלשים יום לנישואין. ויש בגזירת שבעה עשתי עשר דבר ובגזירת שלשים ששה:
The Halakha is according to the Sages when they say: "עצרת כרגלים" and according to Rabban Gamaliel when it (i.e., the Mishnah) states: "ראש השנה ויום הכפורים גרגלים". But if a person buried his dead even one hour prior to the Holiday of Unleavened Bread (i.e., Passover), the decree of Shivah/sitting for seven days is nullified from him. But the seven days of the Festival count from the number [for thirty days], it is found that after the Festival, he counts sixteen days to complete thirty days. And similarly, if he buried his dead even one hour before Shavuot/Atzeret or before Yom Kippur or before Rosh Hashanah, he counts after them sixteen days because they are like the Festivals ((see The Laws of Mourning, Chapter 10, Halakha 3 where he retracted from this (see the note in the previous Halakha) and decided that he counts after Rosh Hashanah and Yom Kippur twenty three days, and he explains that they are like Festivals regarding the fact that one interrupts mourning, but not regarding the the fact that they are considered like Shivah, for they – Rosh Hashanah and Yom Kippur = do not have a Hagigah/sacrifice for seven days – as is brought in Tractate Moed Katan 24b), and therefore, if he buried his dead seven days prior to them, the decree of Shloshim/thirty days is nullified, but if he buried his dead even one hour before the Festival of Sukkot, this nullifies for him the decree of Shivah/sitting for seven days like the law of every festival, and the seven days of the Festival, and the eighth day of the Festival counts for him as seven days because of the general principle among us that the Eighth Day of the Festival is a Festival of its own accord (see Tractate Yoma 20b, Tractate Sukkah 47a, 48a, Tractate Rosh Hashanah 4b and Tractate Hagigah 17a), it is found that there doesn’t remain for him after the Eighth day of the Festival [of Sukkot/also known as Shemini Atzeret] other than nine days from the total number of thirty days (see Tractate Moed Katan 24b). But a person who buries his dead during the Festival (i.e., the Intermediate Days of the Holiday), is not obligated in mourning until after the last day of the Festival, meaning to say, the Second Day of Shemini Atzeret (i.e., Simhat Torah), and he begins from it in the counting of seven days on which he is obligated in the decree of the seven day, and he counts thirty days from the day that his dead passed away, and practices on the rest of the days that are after the Festival the decree of thirty days. But the decree of seven days/Shivah is what I am explaining. All seven days he is required in the lowering of the couch, so that there isn’t in his house a bed which is not lowered, and it is prohibited to engage in sexual relations, and the wearing of leather shoes, and in the performance of work in the open, and in greeting of others and in washing in warm water, and even for part of his body, and in the washing of all of his body in cold water and it is prohibited to engage in anointing, and to read the Torah, and the Bible and the Mishnah and the Talmud, and he is obligated in wrapping up of his head, and this is that he should cover his head and wraps himself up to his lip (i.e., mustache), and it is forbidden to baste the rent , and it is forbidden to cut his fingernails with a utensil and to cut his mustache and even to disturb him at the time that he is eating, nor should he launder his clothing, all of these are an obligation during the course of all of the seven days, and from what that you need to know that on the first day, he does not put on Tefillin, nor eat Holy Things, as we explained in Tractate Pesahim (Chapter 8, Mishnah 10). And he is obligated to sit on an overturned bed on the ground, and he doesn’t eat from what is hi. And on the first three days [of mourning] it is forbidden to perform work, an even in secret, and if they gave him a greeting, he should not return it other than to say to them that he is a mourner. But the decree of Thirty Days/Shloshim, there are six things and these are they: That he does not shave the hair of his head, and does not wear a new white garment that is scoured or folded(see Tractate Shabbat 140a and The Laws of Mourning, Chapter 6, Halakha 4), and he doesn’t mend the garment torn in mourning for the dead, and he doesn’t go to business, and such they said in the Jerusalem Talmud (Chapter 3, Law 8), that on all of the dead, it is prohibited to go to business until thirty days, on ones father and on one’s mother, until his friends rebuke him and say to hm: “Walk with us,” and it is forbidden to drink in the joy of weddings all thirty days, and for his father and for his mother, a year, and it is forbidden to have sexual relations with his second wife that he married, and this is what they said, all thirty days from the day of marriage. It is found that regarding the decree of Seven days/Shivah, there are thirteen laws, as we have explained, and there are six regarding the decree of thirty days.
Sefaria · Rambam on Mishnah Moed Katan 3:6