Moon blessing and its time - 4 subsections. The one who sees the moon in its newness blesses "Who at Their Word created heavens, and at the breath of Their mouth all their hosts; a law and a time They gave unto them, that they would would not change their duty". Note: one should only sanctify the month at night, at the time that the moon shines and we benefit from its light (Agur).
We should only bless regarding the moon on motza'ei Shabbat, when one is perfumed and one's clothes are nice. Note: and this is specifically when motza'ei Shabbat is before the 10th of the Hebrew month, in this case we wait until motza'ei Shabbat. However, if it's after this we don't wait to motza'ei Shabbat, lest there are 2 or 3 or 4 cloudy nights and the moon is invisible, and the time to bless passes. And when we bless the moon during the week, it's good to put on nice clothes (T"H chapter 35). We don't sanctify the moon before Tisha b'Av or before Yom haDin (Maharil), and when Yom Kippur goes out we bless it, since then we exist in a joyful state - but not when Tisha b'Av goes out, or any other fast (my own opinion), and we don't sanctify it on motza'ei Shabbat which falls on Yom Tov (Maharil, laws of Yom Tov). And one fixes their eyes and straightens their legs and blesses (Standing) (Tur) and says three times: "A good sign it will be for all of Israel, Blessed is your Creator etc." Note: and dances three times towards it, and says "Just as I dance, etc", and says "Fear and terror will fall on them, etc" (Shemot 15:16), and again backwards, "Like a stone they will be, etc" three times, and says to one's friend three times "Peace be upon you" (Hagahot haChadashot), and responding to this greeting is like saying it (Tur). And we are accustomed to say "David, King of Israel, lives and exists", since his kingdom is compared to the moon and will in the future be renewed like it. And the assembly of Israel will return and cleave to her Husband, who is the Holy Blessed One, the image of the moon who is renewed with the moon - as it is said, "A sword and a shield is God" (Tehillim 84:12), and therefore we make joys and dance in the sanctification of the month, which is an image of the joy of a wedding. (Bachya, parshat vayeishev, and my own opinion).
Until when do we bless regarding it? Until the 16th day from the day of the molad, not including the 16th itself. One should not sanctify except until half of 29 days, 12 hours, and 793 chalakim from the molad (Teshuvot Maharil)
We do not bless regarding it unitl seven days have passed over it. Note: And we do not sanctify the moon under a roof (Hagahot Alfasi haChadashot)