WHEN CIRCUMCISION IS DOCHEH SHABBOS [Bris Milah: Docheh Shabbos]
Gemara
Question (a man): My son was born on Shabbos, but I heard him cry (earlier in the delivery) on Erev Shabbos. What is considered the day of birth?
Answer (Rava): If you heard him cry, his head already left the Prozdor, so he was born on Erev Shabbos. You may not circumcise him on Shabbos.
(Mishnah): We are not Mechalel Shabbos for a Safek.
(Beraisa): "(Uva'Yom ha'Shmini Yimol Besar) Arlaso" - a Vadai overrides Shabbos, but a Safek does not.
A baby born Bein ha'Shemashos does not override Shabbos. (We do not know which is his eighth day.)
Rishonim
Rambam (Hilchos Milah 1:11): If one was born Bein ha'Shemashos, i.e. Safek during the day, Safek at night, we circumcise him on the ninth day, which is a Safek eighth day (if he was really born at night). If he was born Bein ha'Shemashos of Erev Shabbos, his Bris is not Docheh Shabbos. Rather, he is circumcised on Sunday. We are not Docheh Shabbos for a Safek.
Hagahos Maimoniyos (8): If three medium stars were seen immediately after the baby stuck his head outside, we may rely on them that it is night, even if the coming day is Shabbos (so the Bris will be on Shabbos). However, if the stars delayed to come, if based on the delay it seems that it was day when the head emerged, they judge based on how it seems, and they circumcise him on day eight, even if it is Shabbos. Semag says so, and also my Rebbi (Re'em). It does not depend on Tefilah or accepting Shabbos during the day. These do not cause a leniency or stringency. It depends only on Tzeis ha'Kochavim.
Beis Yosef (OC 331 DH Kasuv bi'Semag): Also the last Hagahos in the Mordechai (470) say so.
Poskim
Shulchan Aruch (OC 331:5): If one was born Bein ha'Shemashos, we do not circumcise him on Shabbos.
Beis Yosef (DH Garsinan): Semag explains that the baby could not have cried had he not stuck his head outside, for as long as he is in the womb, his mouth is closed and the umbilical cord is open.
Bach (2 DH uv'Tinok): If a baby was born on Erev Shabbos close to Bein ha'Shemashos, I wrote (YD 266:12) that if he was born (a quarter of) an hour (one 24th of the day, not a relative hour based on a 12th of the daylight hours that day) before three stars can be seen, we circumcise him on day eight, on Erev Shabbos. If not, it is a Safek, and he is pushed off until Sunday. Even though I wrote (261:2) that regarding Tosefes Shabbos one should be stringent to accept Shabbos at the end of the 22nd hour, regarding Milah we do not say so.
Note: The Magen Avraham's text of the Bach said 'hour' (not quarter-hour), therefore he asked a contradiction in the Bach.
Magen Avraham (2): The Bach is difficult. He himself ruled in YD that (the time to walk) three quarters of a Mil before Tzeis ha'Kochavim is Bein ha'Shemashos. This time is less than a quarter hour, like it says in OC 459:2. Perhaps the Bach erred and thought that it is three Mil. The primary opinion (YD 266:9) is that from Shki'ah, it is a Safek (night). This is from the end of Shki'ah, which is three quarters of a Mil, which is about a quarter hour before Tzeis ha'Kochavim. If he is born before this, he is circumcised on day eight. We rule like this (261:1) even regarding Melachah, which is an Isur Skilah (if it is really Shabbos), and so say Minchas Kohen and the Radvaz. If the baby was born on Shabbos a quarter hour before night, Minchas Kohen said that he should be circumcised on Shabbos, but one should not rely on this unless most Chachmei Yisrael agree, for he did not want to rely on his own opinion regarding Chilul Shabbos, which is very severe. It seems that he was unsure because all Yisraelim in his locale accepted Shabbos at Shki'ah. If so, the same applies to Motza'ei Shabbos. In our land, sometimes people do not accept until almost a quarter-hour before Tzeis ha'Kochavim. If so, one may rely on this regarding Bris Milah to circumcise him on Shabbos, for all great Poskim say so. `
Mishnah Berurah (14): If the baby was born Bein ha'Shemashos of Erev Shabbos or of Motza'ei Shabbos, we do not circumcise him on Shabbos. Some say that Bein ha'Shemashos is close to a quarter-hour (this refers to a relative hour) before three average stars come out. It is Safek night. A quarter-hour removes all Safek. If he was born then on Shabbos, Monim (we count) him for the coming Shabbos.
Note: Perhaps the Mishnah Berurah means that more than a quarter-hour before Tzeis ha'Kochavim is not a Safek, and the text should say (if this was at the end of Shabbos) 'Malim' (we circumcise) him on the coming Shabbos.
Mishnah Berurah (14): However, several Poskim are stringent about this, and say that from when the sun is covered from our eyes until three stars come out, all is included in Bein ha'Shemashos. The Birkei Yosef says so. This is the custom in all cities of Eretz Yisrael. Also Zechor l'Avraham and Seder Zemanim say so. Even if it is a Safek whether he was born before Bein ha'Shemashos or during Bein ha'Shemashos, the Radvaz is stringent to delay the Bris until Sunday. The Acharonim bring his opinion.
Bi'ur Halachah (DH Bein): If it is a Safek whether he was born before Bein ha'Shemashos or during Bein ha'Shemashos, we do not consider this a Sefek-Sefeka. The Pri Megadim says that perhaps we leave her on the Chazakah that she was pregnant. [I think that he said 'perhaps' because it is not a strong Chazakah regarding Dichuy Shabbos. If we are unsure whether a baby was born Erev Shabbos or Shabbos night, and there is no one to ask, e.g. the mother died, we do not say that presumably she gave birth now. Even during the week (when it is merely a question which is day eight), this requires investigation.] Also, we can say that it is all one Safek (whether he was born during the day or at night). Minchas Kohen says so.
Bi'ur Halachah (ibid.): In YD 262:6, we say that if three medium stars were seen immediately after the baby stuck his head outside (we may rely on them that it is night). This is difficult, for in Shabbos (34b) we rule like R. Yosi, who says that when two stars are seen it is Bein ha'Shemashos, and a moment later a third star is seen and it is night. If so, perhaps the third star came out while they were leaving the house (in which she gave birth) to see the stars, and before this it was Bein ha'Shemashos! The Shulchan Aruch's law applies only if they could see the stars at the time of birth, e.g. the door was open and he was looking out the window, and when he heard that the head came out, he immediately looked outside and saw three medium stars. This is difficult. However, if one sees immediately small stars, presumably earlier at the time of birth there were medium stars, for small stars are seen after night. Also this is not so clear. Perhaps they are medium stars, and before were big stars seen during the day. If there are many small stars, surely one may rely on them.
Bi'ur Halachah (ibid.): Derech ha'Chayim says that if the head left the Prozdor, and a while later the entire baby was born after three medium stars came out, if we cannot know (when the head came out), we rely on Chazakah that he was born now. If it was Erev Shabbos, we may circumcise him on Shabbos. He cites the Shach (YD 266:9). This is astounding. We must be concerned lest there were only one or two stars out when the head came out! The Shach is not related to this. Semak (whom the Shach cites) discusses when we do not know whether there was a delay from when the head emerged until the birth, which was Vadai at night. Therefore, we follow the Chazakah, without concern lest there was a delay in between. Here, we know that there was a delay. We cannot rely on the Chazakah, for mid'Oraisa birth was when the head emerged. Perhaps there were only two stars then! I later found that Sidrei Taharah concluded like I said. If we know that there was a delay, we must be stringent to say that the head emerged Bein ha'Shemashos.
Kaf ha'Chayim (35): As long as the sun is seen from the highest thing in the city, we count from that day. When the sun cannot be seen from anywhere in the city, we count from the next day. This is the custom in Yerushalayim and Chevron. The Birkei Yosef says so, based on Beis David. I say that 'when the sun cannot be seen, we count from the next day' applies to weekdays. We circumcise on day nine, which perhaps is really day eight. When the sun cannot be seen, Bein ha'Shemashos begins. If this was on Erev Shabbos, the Bris is not Docheh Shabbos, unless he was born after three stars came out, which is about 40 minutes after the sun cannot be seen.
Kaf ha'Chayim (36): If it is a cloudy day, and people say that based on clocks the sun would be visible if not for the clouds, we rely on them. We are not concerned lest they err.