見出し画像

暦アプリ作ってみようか 6 ~吉神:母倉日(ぼそうにち)かどうか判定してみよう~

今回は吉神側、母倉日(ぼそうにち)であるかどうかの判定を行っていきたいと思います。

母倉日は「母が子を育てるように、天が人を慈しむ」という意味があり、特に結婚や入籍といった慶事に最適な日だそうです。

母倉日は季節毎に日が決められています。

春(立春から立夏の前日まで)「亥・子」の日
夏(立夏から立秋の前日まで)「寅・卯」の日
秋(立秋から立冬の前日まで)「辰・戊・丑・未」の日
冬(立冬から立春の前日まで)「申・酉」の日

これに加えて、各季節の土用期間中の「巳・午」の日が母倉日にあたります。

これをプログラムに組み込む訳ですが、月と日の干支、そして節気のタイミングが分かれば計算できます。今回も引き続きFunction Calc_Kichijinにて判定させるようにしています。ソースは引き続きVB.NET、これまでの連載で作成した関数を使用します。

   Public Function Calc_Kichijin(calc_date As Date) As String

       Dim Tmp_Kichijin As String = ""

       ' 十干リスト
       Dim jikkan() As String = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}

       ' 十二支リスト
       Dim jyuunishi() As String = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}

       ' 24節気のうち、節月の開始日を示す節気の日付を計算
       Dim solar_terms As New Dictionary(Of Integer, Date) From {
       {1, calc_solar_term(calc_date.Year - 1, 23, 285)}, ' 小寒
       {2, calc_solar_term(calc_date.Year, 1, 315)},  ' 立春
       {3, calc_solar_term(calc_date.Year, 3, 345)},  ' 啓蟄
       {4, calc_solar_term(calc_date.Year, 5, 15)},  ' 清明
       {5, calc_solar_term(calc_date.Year, 7, 45)},  ' 立夏
       {6, calc_solar_term(calc_date.Year, 9, 75)},  ' 芒種
       {7, calc_solar_term(calc_date.Year, 11, 105)}, ' 小暑
       {8, calc_solar_term(calc_date.Year, 13, 135)}, ' 立秋
       {9, calc_solar_term(calc_date.Year, 15, 165)}, ' 白露
       {10, calc_solar_term(calc_date.Year, 17, 195)}, ' 寒露
       {11, calc_solar_term(calc_date.Year, 19, 225)}, ' 立冬
       {12, calc_solar_term(calc_date.Year, 21, 255)}  ' 大雪
   }
       ' 月の干支の計算(24節気の節日で切替)
       Dim lunar_month As Integer = 1
       For i As Integer = 1 To 12
           If calc_date >= solar_terms(i) Then
               lunar_month = i + 1
           Else
               Exit For
           End If
       Next
       If lunar_month = 13 Then lunar_month = 1

       ' 日の干支の計算
       ' 基準日を甲子日(1873/1/12)とし、その日からの経過日数を利用
       Dim base_date As Date = CDate("1873/1/12") ' 甲子の日
       Dim days_diff As Integer = (calc_date - base_date).Days
       Dim jikkan_day_index As Integer = days_diff Mod 10
       Dim jyuunishi_day_index As Integer = days_diff Mod 12

       '天赦日かどうかのチェック
       ' 天赦日チェックリスト
       Dim Tensyanichi() As String = {"甲子", "甲子", "戊寅", "戊寅", "戊寅", "甲午", "甲午", "甲午", "戊申", "戊申", "戊申", "甲子"}
       If Tensyanichi(lunar_month - 1) = jikkan(jikkan_day_index) & jyuunishi(jyuunishi_day_index) Then
           Tmp_Kichijin &= "天赦日 "
       End If

       '母倉日(ぼそうにち)かどうかのチェック
       ' 母倉日チェックリスト
       Dim Bosounichi() As String = {"申酉", "申酉", "亥子", "亥子", "亥子", "寅卯", "寅卯", "寅卯", "辰戌丑未", "辰戌丑未", "辰戌丑未", "申酉"}
       Dim Flag_Bosounichi As Boolean = False

       For i As Integer = 1 To Len(Bosounichi(lunar_month - 1))
           If Mid(Bosounichi(lunar_month - 1), i, 1) = jyuunishi(jyuunishi_day_index) Then Flag_Bosounichi = True
       Next

       '各季節の土用の巳・午の日も母倉日
       Dim Chk_Doyou As Integer = 0
       For i = 0 To 3
           Chk_Doyou = (calc_date - solar_terms(3 * i + 2)).Days
           If Chk_Doyou >= -18 And Chk_Doyou < 0 Then
               If jyuunishi(jyuunishi_day_index) = "巳" Or jyuunishi(jyuunishi_day_index) = "午" Then
                   Flag_Bosounichi = True
               End If
           End If
       Next

       If Flag_Bosounichi = True Then
           Tmp_Kichijin &= "母倉日(ぼそうにち) "
       End If

       Return Tmp_Kichijin

   End Function

土用期間は「立春、立夏、立秋、立冬の前18日間」と定義されています。それぞれの節気の日付から何日離れているかで土用期間中かどうか判断しています。

さて、この母倉日ですが、通書や母倉日を扱ったサイトで答え合わせをしていると、母倉日が微妙に異なる日があることに気づきます。例えば2024年1月6日を母倉日として紹介されているサイトが多いのですが、通書では母倉日となっておらず、最寄りの母倉日は2024年1月9日となっています。

本プログラムは通書に沿った結果を返すようにしています。

流派の違いなのか何なのか・・・。謎です。

つづく。

この記事が気に入ったらサポートをしてみませんか?