AddinBox(Title_Logo)

 
    The holiday in Japan  &
        The holiday judgment logic

                                                                                              (Update: 2020 Nov. 28   JST )
 This page introduces the holiday judgment procedures which become
necessary in workday computation and so on in case of computer software development in Japan. The logic is able to be used as a tool to create a
holiday list which becomes necessary in the arguments used in
        WORKDAY / NETWORKDAYS functions (the Analysis ToolPak add-in)
 This page was translated from
        About Holidays  ,  Holiday judgment logic
from Japanese to English.

 The macro code was made in VB syntax only ( The VBA feature of the 
Excel exclusive use is not used. ). Therefore, this macro can also be used 
with MS-Access and other applications that can have VBA programming
features.

 Feel free to use this macro into your macro. But please quote the comment 
(Copyright) shown at the header of this macro.

 Also please don't quote the entire macro code at other web sites. If you 
would like to introduce this macro code, please link to this page instead.

 When using this code in VBA, don't change the code contents of the macro 
absolutely.  This code has been designed in the late VBA language of the
processing speed to process efficiency as much as possible.
 There is a possibility that this efficiency may decline if part of the code is
changed.

The content of this site reflects all the latest revised holiday laws.

    Due to the postponement of the Tokyo Olympics, the following holidays will move
    in 2021 in addition to 2020
    ( a ) Only in 2020
              Marine Day : July 3rd Monday ( 20th July ) to 23th July
              Sports Day : Oct. 2nd Monday ( 12th Oct. ) to 24th July
              Mountain Day : 11th Aug. to 10th Aug.
    ( b ) Only in 2021
              Marine Day : July 3rd Monday ( 19th July ) to 22th July
              Sports Day : Oct. 2nd Monday ( 11th Oct. ) to 23th July
              Mountain Day : 11th Aug. to 8th Aug.

-- Language -- -- Editor -- -- 1st. Release --
VB/VBA AddinBox(K.Tsunoda) Update:2020 Nov. 28 2005 Apr.17th
OOoBasic AddinBox(K.Tsunoda) Update:2020 Nov. 28 2005 Apr.17th
JavaScript AddinBox(K.Tsunoda) Update:2020 Nov. 28 2005 May 5th
 
The attention point when doing a holiday judgment
The usage example ( Bank_Workday / Bank_Networkdays )

The holiday list which can be used by pasting on the Excel sheet and so on can be gotten
from the following. It specifies a creating period by the range in [1948 - 2050].

       to           


      ( Because I who am poor at English am translating into English while using translation software,  
        there may be an odd expression. )



[ Link to here ]
--- About the holiday in Japan by the law ---
 Holiday Name Date Promulgation Enforce 1st Year
 New Year's Day Jan. 1st 1948 Jul. 20th left 1949
 Coming of Age Day Jan. 15th 1948 Jul. 20th left 1949
Jan. [2nd Monday] 1998 Oct. 21th 2000 Jan. 1st 2000
 National Foundation Day Feb. 11th 1966 Jun. 25th left 1967
 Emperor's Birthday
    ( Current prince )
Feb.23th 2017 Jun. 16 2019 May 1st   2020
 Vernal Equinox Day VernalEquinox 1948 Jul. 20th left 1949
 Emperor's Birthday ( Emperor Showa )
      rename "Greenery Day"
      rename "Showa Day"
Apr. 29th 1948 Jul. 20th left 1949
1989 Feb. 17th left 1989
2005 May. 20th 2007 Jan. 1st 2007
 Constitution Memorial Day May 3rd 1948 Jul. 20th left 1949
 Citizen's Holiday
      rename "Greenery Day"
May 4th (*1) 1985 Dec. 27th left 1986
2005 May. 20th 2007 Jan. 1st 2007
 Children's Day May 5th 1948 Jul. 20th left 1949
 Marine Day  Jul.20th 1995 Mar. 8th 1996 Jan. 1st 1996
Jul.[3rd Monday] 2001 Jun. 22th 2003 Jan. 1st 2003
 Only in 2020, it moved to July 23th by the Tokyo Olympic Special Measures Law.
 And only in 2021, it moved to July 22th.
 Mountain Day  Aug. 11th 2014 May. 30th 2016 Jan. 1st 2016
 Only in 2020, it moved to Aug. 10th by the Tokyo Olympic Special Measures Law.
 And only in 2021, it moved to Aug. 8th.
 Respect for the Aged Day Sep.15th 1966 Jun. 25th left 1966
Sep.[3rd Monday] 2001 Jun. 22th 2003 Jan. 1st 2003
 Citizen's Holiday (*2) 2001 Jun. 22th 2003 Jan. 1st 2003
 Autumnal Equinox Day AutumnalEquinox 1948 Jul. 20th left 1948
 Health and Sports Day

            rename "Sports Day"
  
Oct.10th 1966 Jun. 25th left 1966
Oct.[2nd Monday]  1998 Oct. 21th 2000 Jan. 1st 2000
2018 June 13th 2020 Jan. 1st 2020
 Only in 2020, it moved to July 24th by the Tokyo Olympic Special Measures Law
 And only in 2021, it moved to July 23th.
 National Culture Day Nov.3rd 1948 Jul. 20th left 1948
 Labor Thanksgiving Day Nov.23th 1948 Jul. 20th left 1948
 Emperor's Birthday
    ( Emperor Heisei )
Dec.23th 1989 Feb. 17th left   1989
     to 2018
 ( Note )  There is no "Emperor's Birthday" in 2019.
      The reason is the relationship between the dates of
      "the Abdication day (Apr. 30th) and the Enthronement day (May 1st)" and
      "the Change of the Emperor's Birthday (Dec. 23th to Feb. 23th)".
 
---- The holiday by th law which relates to the Imperial Household ----
  The Rite of Wedding of HIH Crown Prince Akihito 1959 Apr.10th
  The Funeral Ceremony of Emperor Showa. 1989 Feb.24th
  The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden) 1990 Nov.12th
  The Rite of Wedding of HIH Crown Prince Naruhito 1993 Jun.9th
  The Enthronement day of HIH Crown Prince Naruhito 2019 May1st
  The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden) 2019 Oct.22th
  ( Note )
        As of May 1, 2019, due to the holidays, April 30, 2019 and May 2 will be citizen's holidays (see below * 3).
 [ Vernal Equinox / Autumnal Equinox ]
    Vernal equinox and Autumnal equinox on the astronomy, it is the following
    range with the year and it changes.
          Vernal Equinox [ 19th to 21th ]   Autumnal Equinox [ 22th to 24th ]
    The date can be calculated by the formula which was introduced in the logic. But it fixes the date of
    the holiday [ Vernal Equinox Day, Autumnal Equinox Day ] by the gazette official announcement
    in February the previous year. Therefore, the holiday [ Vernal Equinox Day, Autumnal Equinox Day ]
    2 years later since then, it becomes the handling "not to be yet decided on the law".


 [ Holiday in Lieu ( or "Substitute Holiday" or "Observed Holiday" or "Transfer Holiday" ) ]
    a) [1973 Apr.12th]  Promulgation and Enforce.
    b) When Sunday becomes a holiday by the law, the next day( Monday )
        becomes in the holiday.
    c) [1973 Feb.11th](Sun)    (Before enforce)
            : Next Monday(Feb.12th) is not "Holiday in Lieu"
        [1973 Apr.29th](Sun) and [Sep.23th](Sun)
            : Next Monday(Apr.30th and Sep.24th) is "Holiday in Lieu"
    d) Since 2007, May 6th is "Holiday in Lieu" in case of Monday, Tuesday
        and Wednesday.


 [ Citizen's Holiday ]
    a) [1985 Dec.27th] Promulgation and Take effect
    b) The day between two holidays by the law becomes in the holiday.

 (*1) May 4th ( 1986 to 2006 )
          May 3rd : Constitution Memorial Day
          May 4th : Citizen's Holiday (between two Holidays)  in case Tue to Sat.
          May 5th : Children's Day
     It is mere Sunday ,when [May 4th] is Sunday.
     It is "Holiday in Lieu" of [Constitution Memorial Day] ,when [May 4th] is Monday.
     May 4th is "Greenery Day" since 2007.

 (*2) September; between [Respect for the Aged Day] and [Autumnal Equinox Day]
          Monday(3rd) : Respect for the Aged Day
          Tuesday        : Citizen's Holiday (between two Holidays)
          Wednesday   : In case, Autumnal Equinox Day
      The year which becomes an object in the period until 2100,
      it is 2009, 2015, 2026, 2032, 2037, 2043, 2049,
      2054, 2060, 2071, 2077, 2088, 2094, 2099.

2008 Sep. S M T W T F S   
   14 15 16 17 18 19 20 15: Respect for the Aged Day (3rd Mon)
   21 22 23 24 25 26 27 23: Autumnal Equinox Day
  
2009 Sep. S M T W T F S 21: Respect for the Aged Day (3rd Mon)
   20 21 22 23 24 25 26 23: Autumnal Equinox Day
  
2010 Sep. S M T W T F S 20: Respect for the Aged Day (3rd Mon)
   19 20 21 22 23 24 25 23: Autumnal Equinox Day

 (*3) 2019 April 29th to May 3rd
        It is the influence of the Enthronement day of HIH Crown Prince Naruhito
        (2019 May 1st) as a temporary holiday.
              Apr. 29th : Showa day
              Apr. 30th : Citizen's Holiday (between two Holidays)
              May  1st : The Enthronement day of HIH Crown Prince Naruhito
              May  2nd : Citizen's Holiday (between two Holidays)
              May  3rd : Constitution Memorial day
        It is only in 2019, but after 2020 (even before 2018) it are not holidays from
        April 30th to May 2nd.

--- About the holiday in the government office and the bank ---

[ Government office ]
  a) The holiday by the law
  b) The weekend ( Saturday & Sunday )
  c) The beginning of the year( Jan.2nd & Jan.3rd)    (Jan.1st is "New Year's Day".)
  d) The end of the year( Dec.29th to Dec.31th )

[ Bank ]
  a) The holiday by the law
  b) The weekend ( Saturday & Sunday )
  c) The beginning of the year( Jan.2nd & Jan.3rd)    (Jan.1st is "New Year's Day".)
  d) The last day of the year( Dec.31th )

--- Japanese era name ---
  Meiji 1868 Oct.23th  to  1912 Jul.29th (M1 to M45)
  Taisho 1912 Jul.30th  to  1926 Dec.24th (T1 to T15)
  Showa 1926 Dec.25th  to  1989 Jan.7th (S1 to S64)
  Heisei 1989 Jan.8th  to  2019 Apr. 30th (H1 to H31)
  Undecided 2019 May 1st to  

  It puts an initial in Japanese era name in front of the year (Era+Year . Month . Day).
        Ex. M43.3.20 , T15.3.20 , S60.3.20 , H17.3.20

  The way of changing the year of Japan with Japanese era name into A.D.
      [ Meiji ]   Year + 1867
      [ Taisho ] Year + 1911
      [ Showa ]  Year + 1925
      [ Heisei ]  Year + 1988
      [ Undecided ]  Year + 2018
  For example, if writing "H17.4.18" , it is "2005 Apr.18th" ( 17 + 1988 = 2005 ).



[ Link to here ]

The attention point when doing a holiday judgment

  In "the workday number computation" and so on, the holiday judgment with tens
of times, hundreds of times, thousands of times must be repeatedly done.
  Because it presupposes use in such processing, the logic to carry on this place has
been designed for a result to be won in the execution of  "the condition judgment"
which is as little as possible. (It made this code, presupposing that it used in VBA.
If comparing the same code with the case to "native compile" in VB, VBA is quite
low-speed. It is making to execute processing efficiently as much as possible even
if it uses in the VBA. Also, because the [And/Or] operator by VBA is Complete type,
there is not to use desirably in this case.)

  When thinking of the 1 year judgment, out of the 365th, the holiday is about 20 days
and about 345 days of the remainder are except the holiday.
  Because it is many, that the day except the holiday is overwhelming, To think of
        "to judge that it is not a holiday how much early"
can improve more in the processing speed than to think of
        "how does it judge a holiday".
It is for its purpose that it adopts the style which doesn't use [And / Or] operator.

  Also, because it is doing a division judgment by "the moon" first, there is not
wastefulness to have executed to "the condition judgment in the other moon"
in January and in September to the date in June.

[Note]
    In case of VB (VBA),The logical operation which was joined by the [And/Or] operator is Complete type.
    Therefore, without using [And/Or] operator to make the coding which omits the judgment which doesn't
    have need, it is necessary to make divide "If" sentence every condition.
    If being Short-circuit type language oppositely, even if it does the coding which gathers a conditional
    expression using the [And/Or] operator, there is not a problem.
    [ Complete type ]
        Even if it is the condition as a result is decided on the way of the formula, it executes all comparative
        calculation until the last.
    [ Short-circuit type ]
        In case of the [And] operator, Not being in what evaluates a right side if the left side is False, it fixes
        the result of the formula in False. In case of the [Or] operator, Not being in what evaluates a right side
        if the left side is True, it fixes the result of the formula in True.
    The way of confirming whether or not it is Short-circuit type is this.


[ Note ]
There is a case which delivers [ Null value ], in the MS-Access. In the such case, it
prepares the function which wraps up [ JpnHolidayName ] and [ JpnHolidayName ]
itself uses without changing.

  Public Function HolidayName(ByVal ChkDate As Variant) As Variant
    If IsDate(ChkDate) Then
      HolidayName = JpnHolidayName(CDate(ChkDate))
    Else
      HolidayName = Null
    End If
  End Function


Besides, in the case to want to make judge together on Saturday and Sunday, too,
for " the bank holiday ", it is possible to correspond in the way of being similar.


  Public Function HolidayName2(ByVal ChkDate As Date) As String
    HolidayName2 = JpnHolidayName(ChkDate)
    If (HolidayName2 = "") Then
      Select Case Weekday(ChkDate)
        Case vbSunday: HolidayName2 = "Sun"
        Case vbSaturday: HolidayName2 = "Sat"
        Case Else
      End Select
    End If
  End Function


Without changing the logic itself of [JpnHolidayName] in being in this way, the various
conditions can be added. When quoting, copy a hand full including the comment without
adding it to [JpnHolidayName] itself.

If a code is added to the inside of JpnHolidayName/prvHoliday, when the public holiday
will be changed again in the future, "the added code" will disappear by overwrite of new
JpnHolidayName / prvHoliday. Also in order not to become such a trouble, without adding
a code to JpnHolidayName/prvHoliday, please prepare a procedure for the outside and
give a functional addition there.


[ Link to here ]

  The way of making a judgment in "the bank holiday"
  When gaining the following code, "is it a bank holiday ? "
  is gotten in [True/False ] to the handed date.


 Public Function Bank_Holiday(ByVal ChkDate As Date) As Boolean
 ' Holiday and Sunday/Saturday and the beginning/last day of the year
  If (JpnHolidayName(ChkDate) <> "") Then
      Bank_Holiday = True    'Holiday
  Else
      Select Case Weekday(ChkDate)
      Case vbSunday
          Bank_Holiday = True
      Case vbSaturday
          Bank_Holiday = True
      Case Else
        Select Case Format(ChkDate, "mmdd")
            Case "0102": Bank_Holiday = True  'the beginning of the year(Jan.2nd)
            Case "0103": Bank_Holiday = True  'the beginning of the year(Jan.3rd)
            Case "1231": Bank_Holiday = True  'the last day of the year(Dec.31th)
            Case Else
                Bank_Holiday = False
        End Select
      End Select
  End If
 End Function


The way of calculating a workday in the bank holiday
  When gaining the following code, A workday is gotten
  if specifying a date and the number of the days.


 Public Function Bank_Workday(ByVal ChkDate As Date, ByVal Days As Integer) As Date
 Dim i As Integer
 Dim wkStep As Integer
 Dim wkDate As Date
  If (Days = 0) Then
      Bank_Workday = ChkDate
      Exit Function
  ElseIf (Days > 0) Then
      wkStep = 1
  Else
      wkStep = -1
  End If
  i = 0
  wkDate = ChkDate
  Do
      wkDate = wkDate + wkStep
      If (Bank_Holiday(wkDate) = False) Then
          i = i + wkStep
      End If
  Loop Until (i = Days)
  Bank_Workday = wkDate
 End Function

-- Calculation example (It is the same as WORKDAY function of the analysis tool.) --
  [ Days =  1 ]  .... The next business day of ChkDate.
  [ Days = -1 ]  .... The previous business day of ChkDate.
  [ Days =  0 ]  .... The day of ChkDate ( ChkDay is a business day or a holiday. )




It becomes the following function if finding the number of the workdays.

( 2016 March 5 : Correct )
  Because I misunderstood True/False of the If statement,
  I calculated the number of the holiday not the number of the business day.


 Public Function Bank_Networkdays _
        (ByVal StartDay As Date, ByVal EndDay As Date) As Integer
 Dim wkDate As Date
 Dim wkStep As Integer
 Dim intDays As Integer
    if (StartDay <= EndDay) Then
      wkStep = 1
    Else
      wkStep = -1
    End If
    intDays = 0
    For wkDate = StartDay To EndDay Step wkStep
        ' ---  2016 Mar 5 : correct follows "True" to "False"  ---
        If (Bank_Holiday(wkDate) = False) Then
          intDays = intDays + wkStep
        End If
    Next wkDate
    Bank_Networkdays = intDays
 End Function

-- Calculation example (It is the same as NETWORKDAYS function of the analysis tool.) --
  [ EndDay = StartDay ] .... 1 ( When StartDay is a holiday; the result is 0. )
  [ EndDay = The next business day of StartDay ] .... 2 ( When StartDay is a holiday; the result is 1. )
  [ EndDay = The previous business day of StartDay ] .... -2 ( When StartDay is a holiday; the result is -1. )




Making Japanese Holiday List
    It is possible to use as the tool which creates the holiday list
    which becomes necessary in the argument with WORKDAY /
    NETWORKDAYS ( Excel analysis tool ) function.

 Public Sub HolidayList( )
 Dim MyDate As Date
 Dim StartDate As Date
 Dim EndDate As Date
 Dim strHoliday As String
 Const cstYear As Integer = 2005

    StartDate = DateSerial(cstYear, 1, 1)
    EndDate = DateSerial(cstYear, 12, 31)

    For MyDate = StartDate To EndDate Step 1
        strHoliday = JpnHolidayName(MyDate)
        If (strHoliday <> "") Then
            With ActiveCell
                .Value = Format(MyDate, "yyyy/m/d")
                .Offset(0, 1).Value = Format(MyDate, "ddd")
                .Offset(0, 2).Value = strHoliday
                .Offset(1, 0).Activate
            End With
        End If
    Next MyDate
 End Sub



[ Link to here ]

[ The holiday judgment macro for VB and VBA ]
    2005 May 26th    It changed "Showa's Day" into "Showa Day".
    2014 May 29th    "Mountain Day" is added.)
    2018 Feb. 15th    "the change of the Emperor's Birthday" is added.
    2018 June 21th    Renamed "Health and Sports Day"  ( to "Sports Day" )  and
                                  "Movement of public holidays" only in 2020 by the Olympic Special Measures Law.

    2018 Dec. 8th    It corresponds to the revision of the following holidays.
                                  2019 May 1st   "The Enthronement day of HIH Crown Prince Naruhito"
                                  2019 Apr. 30th & May 2nd   "Citizen's Holiday" to be sandwiched on two holidays
                                  2019 Oct. 22th   "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"

    2020 Nov. 28th   "Movement of public holidays" only in 2021 by the Olympic Special Measures Law.

When adding conditions such as judging the weekend and so on together,
it refers to "The attention point when doing a holiday judgment".

As for the contents in the holiday, it refers to "about the holiday in Japan".
----------------------------------------------------------------------------------------

 

'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'_/
'_/    ==== Japanese Holiday Check Function ( VB/VBA , Update: 2020 Nov. 28 ) ====
'_/
'_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
'_/  ( AddinBox  http://addinbox.sakura.ne.jp/index.htm )
'_/  (   Old Site  http://www.h3.dion.ne.jp/~sakatsu/index.htm )
'_/
'_/  The holiday which was defined by the present holiday law can be won in this macro.
'_/  The holidays changes supported by this macro are as follows.
'_/  ( a ) Change date of "Emperorfs Birthday" enforced in 2019. ( 23th Dec. to 23th Feb. )
'_/          (Note: There is no "Emperorfs Birthday" in 2019.)
'_/  ( b ) May 1st 2019 is "The Enthronement day of HIH Crown Prince Naruhito".
'_/          April 30th and May 2nd 2019 are holidays because they are sandwiched between national holidays.
'_/          In addition, April 30th is Emperor Heiseifs abdication day.
'_/  ( c ) Oct. 22th 2019 is "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
'_/  ( d ) Renamed "Health and Sports Day" enforced in 2020. ( to "Sports Day" )
'_/  ( e ) "Movement of public holidays" only in 2020 by the Olympic Special Measures Law.
'_/              Marine Day : 20th July ( 3rd Monday ) to 23th July
'_/              Sports Day : 12th Oct. ( 2nd momnday ) to 24th July
'_/              Mountain Day : 11th Aug. to 10th Aug.
'_/  ( f ) "Movement of public holidays" only in 2021 by the Olympic Special Measures Law.
'_/              Marine Day : 19th July ( 3rd Monday ) to 22th July
'_/              Sports Day : 11th Oct. ( 2nd momnday ) to 23th July
'_/              Mountain Day : 11th Aug. to 8th Aug.
'_/
'_/  This logic made to improve a response the most priority
'_/  and designed that it is possible to let out a result by
'_/  " the execution of the condition judgment " with little
'_/  number of times as far as it is possible for its purpose.
'_/  It is for its purpose that it adopts the style which doesn't
'_/  use [And/Or] operator.
'_/
'_/  (*1) When quoting this macro, always together quote
'_/          the comment which is mentioned to here.
'_/
'_/  (*2) It prohibits to quote this whole macro code in the
'_/          other site and to carry. When introducing this macro,
'_/          do following URL only to mention it.
'_/      [ http://addinbox.sakura.ne.jp/holiday_logic_English.htm ]
'_/
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


Public Function JpnHolidayName(ByVal ChkDate As Date) As String
Dim dtmDate As Date
Dim strHoliday As String
' Date of Enforcement of Holidays in Lieu
Const cstEnforcementDate_HolidayInLieu As Date = #1973 April 12#

    ' Remove Time Serial Value(Decimal number)
    dtmDate = DateSerial(Year(ChkDate), Month(ChkDate), Day(ChkDate))

    strHoliday = prvHoliday(dtmDate)
    If (strHoliday = "") Then
        If (Weekday(dtmDate) = vbMonday) Then
            ' In the day except Monday, it doesn't need a judgement in [Holiday in Lieu]
            ' In May 6th ( Tuesday, Wednesday ), it has judged in prvHolidayChk.
            ' In May 6th ( Monday ), it judges here.

            If (dtmDate >= cstEnforcementDate_HolidayInLieu) Then    ' [1973 Apr.12th]
                strHoliday = prvHoliday(dtmDate - 1)
                If (strHoliday <> "") Then
                    ' When the day before ChkDate is Holiday and Sunday,
                    ' ChkDate is [Holiday in Lieu]

                    JpnHolidayName = "Holiday in Lieu"
                Else
                    JpnHolidayName = ""
                End If
            Else
                JpnHolidayName = ""
            End If
        Else
            JpnHolidayName = ""
        End If
    Else
        JpnHolidayName = strHoliday
    End If
End Function

'========================================================================
Private Function prvHoliday(ByVal ChkDate As Date) As String
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
Dim intAutumnalEquinox As Integer
Dim strWeek As String    ' [1st, 2nd, 3rd, 4th] + [Day of Week(1 to 7)]

'Date of Enforcement of the Holidays Law
Const cstEnforcementDate_Holiday_Law As Date = #1948 July 20#
'The Funeral Ceremony of Emperor Showa.
Const cstFuneralCeremony_Showa As Date = #1989 February 24#
'The Rite of Wedding of HIH Crown Prince Akihito
Const cstWeddingHIH_Akihito As Date = #1959 April 10#
'The Rite of Wedding of HIH Crown Prince Naruhito
Const cstWeddingHIH_Naruhito As Date = #1993 June 9#
'The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)
Const cstCeremonyEnthronement As Date = #1990 November 12#

' Emperor Heisei's abdication day
' It is a holiday because it is sandwiched between national holidays.
Const cstEmperorHeisei_AbdicationDay As Date = #2019 April 30#
' The Enthronement day of HIH Crown Prince Naruhito
Const cstEnthronementDay_Naruhito As Date = #2019 May 1#
' It is a holiday because it is sandwiched between national holidays.
Const cst2019_May2nd As Date = #2019 May 2#
' The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)
Const cstCeremonyEnthronement_Naruhito As Date = #2019 October 22#

    intYear = Year(ChkDate)
    intMonth = Month(ChkDate)
    intDay = Day(ChkDate)

    prvHoliday = ""
    If (ChkDate < cstEnforcementDate_Holiday_Law) Then    ' [1948 Jul.20th]
        Exit Function    ' before Date of Enforcement of the Holidays Law
    End If

    Select Case intMonth
' // January //
    Case 1
        If (intDay = 1) Then
            prvHoliday = "New Year's Day"
        Else
            If (intYear >= 2000) Then
                strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
                If (strWeek = "22") Then  ' 2nd Monday
                    prvHoliday = "Coming of Age Day"
                End If
            Else
                If (intDay = 15) Then
                    prvHoliday = "Coming of Age Day"
                End If
            End If
        End If

' // February //
    Case 2
        If (intDay = 11) Then
            If (intYear >= 1967) Then
                prvHoliday = "National Foundation Day"
            End If
        ElseIf (intDay = 23) Then
            If (intYear >= 2020) Then
                prvHoliday = "Emperor's Birthday"
            End If
        ElseIf (ChkDate = cstFuneralCeremony_Showa) Then    ' [1989 Feb.24th]
            prvHoliday = "The Funeral Ceremony of Emperor Showa."
        End If

' // March //
    Case 3
        If (intDay = prvVernalEquinox(intYear)) Then
            ' Because 99 returns except the range from 1948 to 2150,
            ' it doesn't become an equal.
            prvHoliday = "Vernal Equinox Day"
        End If

' // April //
    Case 4
        If (intDay = 29) Then
            If (intYear >= 2007) Then
                prvHoliday = "Showa Day"
            ElseIf  (intYear >= 1989) Then
                prvHoliday = "Greenery Day"
            Else
                prvHoliday = "Emperor's Birthday' Birthday of Emperor Showa.
            End If
        ' It is sandwiched between national holidays (April 29th and May 1st).
        ElseIf (ChkDate = cstEmperorHeisei_AbdicationDay) Then    ' [2019 Apr.30th]
            prvHoliday = "Citizen's Holiday"
        ElseIf (ChkDate = cstWeddingHIH_Akihito) Then    ' [1959 Apr.10th]
            prvHoliday = "The Rite of Wedding of HIH Crown Prince Akihito"
        End If

' // May //
    Case 5
        If (intDay = 3) Then
            prvHoliday = "Constitution Memorial Day"
        ElseIf (intDay = 4) Then
            If (intYear >= 2007) Then
                prvHoliday = "Greenery Day"
            ElseIf (intYear >= 1986) Then
                ' It is mere Sunday ,when [May 4th] is Sunday
                ' It is Holiday in lieu of [Constitution Memorial Day] ,when [May 4th] is Monday
                If (Weekday(ChkDate) > vbMonday) Then  ' After Tuesday (Tue - Sat)
                    prvHoliday = "Citizen's Holiday"
                End If
            End If
        ElseIf (intDay = 5) Then
            prvHoliday = "Children's Day"
        ElseIf (intDay = 6) Then
            If (intYear >= 2007) Then
                Select Case Weekday(ChkDate)
                    Case vbTuesday, vbWednesday
                        ' When May 3rd or May 4th becomes on Sunday, it judges here.
                        prvHoliday = "Holiday in Lieu"
                End Select
            End If
        Else
            If (intYear = 2019) Then
                If (ChkDate = cstEnthronementDay_Naruhito) Then    ' 2019 May 1st
                    prvHoliday = "The Enthronement day of HIH Crown Prince Naruhito"
                ElseIf (ChkDate = cst2019_May2nd) Then    ' 2019 May 2nd
                    ' It is sandwiched between national holidays (May 1st and May 3rd)
                    prvHoliday = "Citizen's Holiday"
                End If
            End If
        End If

' // June //
    Case 6
        If (ChkDate = cstWeddingHIH_Naruhito) Then    ' [1993 Jun.9th]
            prvHoliday = "The Rite of Wedding of HIH Crown Prince Naruhito"
        End If

' // July //
    Case 7
        strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
        Select Case intYear
          Case Is >= 2022
            If (strWeek = "32") Then  '3rd Monday(2)
                prvHoliday = "Marine Day"
            End If
          Case 2021
            ' "Marine Day" moved to July 22th, "Sports Day" moved to July 23th
            ' by the Olympic Special Measures Law in 2021.
            Select Case intDay
              Case 22
                prvHoliday = "Marine Day"
              Case 23
                prvHoliday = "Sports Day"
              Case Else
            End Select
          Case 2020
            ' "Marine Day" moved to July 23th, "Sports Day" moved to July 24th
            ' by the Olympic Special Measures Law in 2020.
            Select Case intDay
              Case 23
                prvHoliday = "Marine Day"
              Case 24
                prvHoliday = "Sports Day"
              Case Else
            End Select
          Case Is >= 2003
            If (strWeek = "32") Then  '3rd Monday(2)
                prvHoliday = "Marine Day"
            End If
          Case Is >= 1996
            If (intDay = 20) Then
                prvHoliday = "Marine Day"
            End If
          Case Else
        End Select

' // August //
    Case 8
        Select Case intYear
          Case Is >= 2022
            If (intDay = 11) Then
                prvHoliday = "Mountain Day"
            End If
          Case 2021
            ' "Mountain Day" moved to August 8th by the Olympic Special Measures Law in 2021.
            If (intDay = 8) Then
                prvHoliday = "Mountain Day"
            End If
          Case 2020
            ' "Mountain Day" moved to August 10th by the Olympic Special Measures Law in 2020.
            If (intDay = 10) Then
                prvHoliday = "Mountain Day"
            End If
          Case Is >= 2016
            If (intDay = 11) Then
                prvHoliday = "Mountain Day"
            End If
          Case Else
        End Select

' // September //
    Case 9
        ' 3rd Monday(15th to 21th) and Autumnal Equinox day(22th to 24th) never agree
        intAutumnalEquinox = prvAutumnalEquinox(intYear)
        If (intDay = intAutumnalEquinox) Then
            ' Because 99 returns except the range from 1948 to 2150,
            ' it doesn't become an equal.
            prvHoliday = "Autumnal Equinox Day"
        Else
            If (intYear >= 2003) Then
                strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
                If (strWeek = "32") Then  ' 3rd Monday
                    prvHoliday = "Respect for the Aged Day"
                ElseIf (Weekday(ChkDate) = vbTuesday) Then
                    If (intDay = (intAutumnalEquinox - 1)) Then
                        ' Monday(3rd) : Respect for the Aged Day
                        ' Tuesday     : Citizen's Holiday (between two Holidays)
                        ' Wednesday   : In case, Autumnal Equinox Day

                        prvHoliday = "Citizen's Holiday"
                    End If
                End If
            ElseIf (intYear >= 1966) Then
                If (intDay = 15) Then
                    prvHoliday = "Respect for the Aged Day"
                End If
            End If
        End If

' // October //
    Case 10
        strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
        Select Case intYear
          Case Is >= 2022
            If (strWeek = "22") Then  '2nd Monday(2)
                prvHoliday = "Sports Day'rename since 2020
            End If
          Case 2020 , 2021
            ' "Sports Day" moved to July 23th by the Olympic Special Measures Law in 2021.
            ' "Sports Day" moved to July 24th by the Olympic Special Measures Law in 2020.
          Case Is >= 2000
            If (strWeek = "22") Then  '2nd Monday(2)
                prvHoliday = "Health and Sports Day"
            ElseIf (ChkDate = cstCeremonyEnthronement_Naruhito) Then    ' 2019 Oct. 22 (HIH Crown Prince Naruhito)
                prvHoliday = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
            End If
          Case Is >= 1966
            If (intDay = 10) Then
                prvHoliday = "Health and Sports Day"
            End If
          Case Else
        End Select

' // November //
    Case 11
        If (intDay = 3) Then
            prvHoliday = "National Culture Day"
        ElseIf (intDay = 23) Then
            prvHoliday = "Labor Thanksgiving Day"
        ElseIf (ChkDate = cstCeremonyEnthronement) Then    ' [1990 Nov.12th]
            prvHoliday = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
        End If

' // December //
    Case 12
        If (intDay = 23) Then
            If ((intYear >= 1989) And (intYear <= 2018)) Then
                prvHoliday = "Emperor's Birthday' Birthday of Emperor Heisei.
            End If
        End If
    End Select
End Function

'======================================================================
'  This simple computation formula of VernalEquinox and AutumnalEquinox is presented by
'    Japan Coast Guard / Hydrographic and Oceanographic Department
'    [ Sin Koyomi Benrichou (ISBN4-7699-0700-1) ]


Private Function prvVernalEquinox(ByVal ChkYear As Integer) As Integer
    If (ChkYear <= 1947) Then
        prvVernalEquinox = 99        ' before Date of Enforcement of the Holidays Law
    ElseIf (ChkYear <= 1979) Then
        prvVernalEquinox = Int(20.8357 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    ElseIf (ChkYear <= 2099) Then
        prvVernalEquinox = Int(20.8431 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    ElseIf (ChkYear <= 2150) Then
        prvVernalEquinox = Int(21.851 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    Else
        prvVernalEquinox = 99        'VernalEquinoxDay is unknown after 2151
    End If
End Function

'========================================================================
Private Function prvAutumnalEquinox(ByVal ChkYear As Integer) As Integer
    If (ChkYear <= 1947) Then
        prvAutumnalEquinox = 99        ' before Date of Enforcement of the Holidays Law
    ElseIf (ChkYear <= 1979) Then
        prvAutumnalEquinox = Int(23.2588 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    ElseIf (ChkYear <= 2099) Then
        prvAutumnalEquinox = Int(23.2488 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    ElseIf (ChkYear <= 2150) Then
        prvAutumnalEquinox = Int(24.2488 + (0.242194 * (ChkYear - 1980)) - Int((ChkYear - 1980) / 4))
    Else
        prvAutumnalEquinox = 99        'AutumnalEquinoxDay is unknown after 2151
    End If
End Function

' (Note) Year=1948 to 1979
' VernalEquinox = [20.8357 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
' AutumnalEquinox = [23.2588 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
' [A] is the gauss symbol. The integer which doesn't over A. [-5 / 4] = [-1.25]= -2
' VB or VBA : Int(-5/4)= -2  Fix(-5/4)= -1
' C language : Int(-5/4)= -1
' Formula when VB or VBA using [Fix] is Fix((ChkYear - 1983) / 4) in from 1948 to 1979.
' Formula for C language is  Int((ChkYear - 1983) / 4) in from 1948 to 1979.


'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



[ Link to here ]


[ The holiday judgment macro for OpenOffice.org Basic ]  ( Apache OpenOffice , LibreOffice )
    2005 May 26th    It changed "Showa's Day" into "Showa Day".)
    2014 May 29th    "Mountain Day" is added.)
    2018 Feb. 15th    "the change of the Emperor's Birthday" is added.)
    2018 June 21th    Renamed "Health and Sports Day"  ( to "Sports Day" )  and
                                  "Movement of public holidays" only in 2020 by the Olympic Special Measures Law. )
    2018 Dec. 8th    It corresponds to the revision of the following holidays.
                                  2019 May 1st   "The Enthronement day of HIH Crown Prince Naruhito"
                                  2019 Apr. 30th & May 2nd   "Citizen's Holiday" to be sandwiched on two holidays
                                  2019 Oct. 22th   "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
    2020 Nov. 28th   "Movement of public holidays" only in 2021 by the Olympic Special Measures Law.

    It transplanted this holiday judgment macro from the VBA macro
    for [OpenOffice.org Basic]. The change point by the difference of
    the specification with VBA is the following.
        (1) Because there are not VB fixed numbers such as vbMonday, it prepares
            a fixed number newly.
       (2) Because the execution speed fell extremely when specifying the date-string
            which was surrounded in ["] in the fixed number definition, it changes into
            the specification by the date-literal which was surrounded in [#].
            OOoBasic becomes a value [48.975], with date literal [#1959/4/10#] interpreted
            as being merely division. Therefore, it changes as the definition of the fixed
            number at serial value [21650].
       (3) The "Private" declaration is ignored and appears in the macro dialog.
            Therefore, without making "prvHoliday/prvVernalEquinox/
            prvAutumnalEquinox" an individual routine, it gathers completely
            in "JpnHolidayName".
       (4) With (3) changes, it arranges the judgment of "Holiday in lieu" to the last
            in the routine and it executes it with "Recursive Call".

    It works in VBA even if it doesn't correct macro for OOoBasic absolutely.

    When adding conditions such as judging the weekend and so on together,
    it refers to "The attention point when doing a holiday judgment".

    As for the contents in the holiday, it refers to "about the holiday in Japan".

----------------------------------------------------------------------------------------
 


'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'_/
'_/    ==== Japanese Holiday Check Function ( OOo.Basic , Update: 2018 Dec. 8 ) ====
'_/        ( Apache OpenOffice , LibreOffice )
'_/
'_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
'_/  ( AddinBox  http://addinbox.sakura.ne.jp/index.htm )
'_/  (  Old Site  http://www.h3.dion.ne.jp/~sakatsu/index.htm )
'_/
'_/  It transplanted this holiday judgment macro
'_/  from the VBA macro for [OpenOffice.org Basic ( LibreOffice / ApacheOffice )].
'_/
'_/  The holiday which was defined by the present holiday law can be won in this macro.
'_/  The holidays changes supported by this macro are as follows.
'_/  ( a ) Change date of "Emperorfs Birthday" enforced in 2019. ( 23th Dec. to 23th Feb. )
'_/          (Note: There is no "Emperorfs Birthday" in 2019.)
'_/  ( b ) May 1st 2019 is "The Enthronement day of HIH Crown Prince Naruhito".
'_/          April 30th and May 2nd 2019 are holidays because they are sandwiched between national holidays.
'_/          In addition, April 30th is Emperor Heiseifs abdication day.
'_/  ( c ) Oct. 22th 2019 is "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
'_/  ( d ) Renamed "Health and Sports Day" enforced in 2020. ( to "Sports Day" )
'_/  ( e ) "Movement of public holidays" only in 2020 by the Olympic Special Measures Law.
'_/          Marine Day : 20th July ( 3rd Monday ) to 23th July
'_/          Sports Day : 12th Oct. ( 2nd momnday ) to 24th July
'_/          Mountain Day : 11th Aug. to 10th Aug.
'_/  ( f ) "Movement of public holidays" only in 2021 by the Olympic Special Measures Law.
'_/          Marine Day : 19th July ( 3rd Monday ) to 22th July
'_/          Sports Day : 11th Oct. ( 2nd momnday ) to 23th July
'_/          Mountain Day : 11th Aug. to 8th Aug.
'_/
'_/  This logic made to improve a response the most priority
'_/  and designed that it is possible to let out a result by
'_/  " the execution of the condition judgment " with little
'_/  number of times as far as it is possible for its purpose.
'_/  It is for its purpose that it adopts the style which doesn't
'_/  use [And/Or] operator.
'_/
'_/  (*1) When quoting this macro, always together quote
'_/          the comment which is mentioned to here.
'_/
'_/  (*2) It prohibits to quote this whole macro code in the
'_/          other site and to carry. When introducing this macro,
'_/          do following URL only to mention it.
'_/      [ http://addinbox.sakura.ne.jp/holiday_logic_English.htm ]
'_/ 
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


Function JpnHolidayName(ByVal ChkDate As Date) As String
Dim strHoliday As String
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
Dim intVernalEquinox As Integer
Dim intAutumnalEquinox As Integer
Dim strWeek As String  ' [1st, 2nd, 3rd, 4th] + [Day of Week(1 to 7)]
Const cstMonday As Integer = 2
Const cstTuesday As Integer = 3
Const cstWednesday As Integer = 4

'Date of Enforcement of the Holidays Law #1948 July 20#
Const cstEnforcementDate_Holiday_Law As Date = 17734
' Date of Enforcement of Holidays in Lieu #1973 April 12#
Const cstEnforcementDate_HolidayInLieu As Date = 26766
'The Funeral Ceremony of Emperor Showa. #1989 February 24#
Const cstFuneralCeremony_Showa As Date = 32563
'The Rite of Wedding of HIH Crown Prince Akihito #1959 April 10#
Const cstWeddingHIH_Akihito As Date = 21650
'The Rite of Wedding of HIH Crown Prince Naruhito #1993 June 9#
Const cstWeddingHIH_Naruhito As Date = 34129
'The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden) #1990 November 12#
Const cstCeremonyEnthronement As Date = 33189

' Emperor Heisei's abdication day
' It is a holiday because it is sandwiched between national holidays.
Const cstEmperorHeisei_AbdicationDay As Date = 43585    '#2019 April 30#
' The Enthronement day of HIH Crown Prince Naruhito
Const cstEnthronementDay_Naruhito As Date = 43586    '#2019 May 1#
' It is a holiday because it is sandwiched between national holidays.
Const cst2019_May2nd As Date = 43587    '#2019 May 2#
' The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)
Const cstCeremonyEnthronement_Naruhito As Date = 43760    '#2019 October 22#

    intYear = Year(ChkDate)
    intMonth = Month(ChkDate)
    intDay = Day(ChkDate)

    strHoliday = ""
    If (ChkDate < cstEnforcementDate_Holiday_Law) Then    ' [1948 Jul.20th]
        JpnHolidayName = ""    ' before Date of Enforcement of the Holidays Law
        Exit Function
    End If

    Select Case intMonth
' // January //
    Case 1
        If (intDay = 1) Then
            strHoliday = "New Year's Day"
        Else
            If (intYear >= 2000) Then
                strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
                If (strWeek = "22") Then  ' 2nd Monday
                    strHoliday = "Coming of Age Day"
                End If
            Else
                If (intDay = 15) Then
                    strHoliday = "Coming of Age Day"
                End If
            End If
        End If

' // February //
    Case 2
        If (intDay = 11) Then
            If (intYear >= 1967) Then
                strHoliday = "National Foundation Day"
            End If
        ElseIf (intDay = 23) Then
            If (intYear >= 2020) Then
                strHoliday = "Emperor's Birthday"
            End If
        ElseIf (ChkDate = cstFuneralCeremony_Showa) Then    ' [1989 Feb.24th]
            strHoliday = "The Funeral Ceremony of Emperor Showa."
        End If

' // March //
    Case 3
        ' This simple computation formula of VernalEquinox and AutumnalEquinox is presented by
        '  Japan Coast Guard / Hydrographic and Oceanographic Department
        '  [ Sin Koyomi Benrichou (ISBN4-7699-0700-1) ]

        If (intYear <= 1947) Then
            intVernalEquinox = 99        ' before Date of Enforcement of the Holidays Law
        ElseIf (intYear <= 1979) Then
            intVernalEquinox = Int(20.8357 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        ElseIf (intYear <= 2099) Then
            intVernalEquinox = Int(20.8431 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        ElseIf (intYear <= 2150) Then
            intVernalEquinox = Int(21.851 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        Else
            intVernalEquinox = 99        ' VernalEquinoxDay is unknown after 2151
        End If

        If (intDay = intVernalEquinox) Then
            ' Because 99 returns except the range from 1948 to 2150,
            ' it doesn't become an equal.
            strHoliday = "Vernal Equinox Day"
        End If

' // April //
    Case 4
        If (intDay = 29) Then
            If (intYear >= 2007) Then
                strHoliday = "Showa Day"
            ElseIf  (intYear >= 1989) Then
                strHoliday = "Greenery Day"
            Else
                strHoliday = "Emperor's Birthday' Birthday of Emperor Showa.
            End If
        ' It is sandwiched between national holidays (April 29th and May 1st).
        ElseIf (ChkDate = cstEmperorHeisei_AbdicationDay) Then    ' [2019 Apr.30th]
            prvHoliday = "Citizen's Holiday"
        ElseIf (ChkDate = cstWeddingHIH_Akihito) Then    ' [1959 Apr.10th]
            strHoliday = "The Rite of Wedding of HIH Crown Prince Akihito"
        End If

' // May //
    Case 5
        If (intDay = 3) Then
            strHoliday = "Constitution Memorial Day"
        ElseIf (intDay = 4) Then
            If (intYear >= 2007) Then
                strHoliday = "Greenery Day"
            ElseIf (intYear >= 1986) Then
                'It is mere Sunday ,when [May 4th] is Sunday
                ' It is Holiday in lieu of [Constitution Memorial Day] ,when [May 4th] is Monday
                If (Weekday(ChkDate) > cstMonday) Then  ' After Tuesday (Tue - Sat)
                    strHoliday = "Citizen's Holiday"
                End If
            End If
        ElseIf (intDay = 5) Then
            strHoliday = "Children's Day"
        ElseIf (intDay = 6) Then
            If (intYear >= 2007) Then
                Select Case Weekday(ChkDate)
                    Case cstTuesday, cstWednesday
                        ' When May 3rd or May 4th becomes on Sunday, it judges here.
                        strHoliday = "Holiday in Lieu"
                End Select
            End If
        Else
            If (intYear = 2019) Then
                If (ChkDate = cstEnthronementDay_Naruhito) Then    ' 2019 May 1st
                    prvHoliday = "The Enthronement day of HIH Crown Prince Naruhito"
                ElseIf (ChkDate = cst2019_May2nd) Then    ' 2019 May 2nd
                    ' It is sandwiched between national holidays (May 1st and May 3rd)
                    prvHoliday = "Citizen's Holiday"
                End If
            End If
        End If

' // June //
    Case 6
        If (ChkDate = cstWeddingHIH_Naruhito) Then    ' [1993 Jun.9th]
            strHoliday = "The Rite of Wedding of HIH Crown Prince Naruhito"
        End If

' // July //
    Case 7
        strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
        Select Case intYear
          Case Is >= 2022
            If (strWeek = "32") Then  '3rd Monday(2)
                strHoliday = "Marine Day"
            End If
          Case 2021
            ' "Marine Day" moved to July 22th, "Sports Day" moved to July 23th
            ' by the Olympic Special Measures Law in 2021.
            Select Case intDay
              Case 22
                strHoliday = "Marine Day"
              Case 23
                strHoliday = "Sports Day"
              Case Else
            End Select
          Case 2020
            ' "Marine Day" moved to July 23th, "Sports Day" moved to July 24th
            ' by the Olympic Special Measures Law in 2020.
            Select Case intDay
              Case 23
                strHoliday = "Marine Day"
              Case 24
                strHoliday = "Sports Day"
              Case Else
            End Select
          Case Is >= 2003
            If (strWeek = "32") Then  '3rd Monday(2)
                strHoliday = "Marine Day"
            End If
          Case Is >= 1996
            If (intDay = 20) Then
                strHoliday = "Marine Day"
            End If
          Case Else
        End Select

' // August //
    Case 8
        Select Case intYear
          Case Is >= 2022
            If (intDay = 11) Then
                strHoliday = "Mountain Day"
            End If
          Case 2021
            ' "Mountain Day" moved to August 8th by the Olympic Special Measures Law in 2021.
            If (intDay = 8) Then
                strHoliday = "Mountain Day"
            End If
          Case 2020
            ' "Mountain Day" moved to August 10th by the Olympic Special Measures Law in 2020.
            If (intDay = 10) Then
                strHoliday = "Mountain Day"
            End If
          Case Is >= 2016
            If (intDay = 11) Then
                strHoliday = "Mountain Day"
            End If
          Case Else
        End Select

' // September //
    Case 9
        ' This simple computation formula of VernalEquinox and AutumnalEquinox is presented by
        '  Japan Coast Guard / Hydrographic and Oceanographic Department
        '  [ Sin Koyomi Benrichou (ISBN4-7699-0700-1) ]

        If (intYear <= 1947) Then
            intAutumnalEquinox = 99        ' before Date of Enforcement of the Holidays Law
        ElseIf (intYear <= 1979) Then
            intAutumnalEquinox = Int(23.2588 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        ElseIf (intYear <= 2099) Then
            intAutumnalEquinox = Int(23.2488 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        ElseIf (intYear <= 2150) Then
            intAutumnalEquinox = Int(24.2488 + (0.242194 * (intYear - 1980)) - Int((intYear - 1980) / 4))
        Else
            intAutumnalEquinox = 99        ' AutumnalEquinoxDay is unknown after 2151
        End If

        ' 3rd Monday(15th to 21th) and Autumnal Equinox day(22th to 24th) never agree
        If (intDay = intAutumnalEquinox) Then
            ' Because 99 returns except the range from 1948 to 2150,
            ' it doesn't become an equal.
            strHoliday = "Autumnal Equinox Day"
        Else
            If (intYear >= 2003) Then
                strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
                If (strWeek = "32") Then      ' 3rd Monday
                    strHoliday = "Respect for the Aged Day"
                ElseIf (Weekday(ChkDate) = cstTuesday) Then
                    If (intDay = (intAutumnalEquinox - 1)) Then
                        ' Monday(3rd) : Respect for the Aged Day
                        ' Tuesday     : Citizen's Holiday (between two Holidays)
                        ' Wednesday   : In case, Autumnal Equinox Day

                        strHoliday = "Citizen's Holiday"
                    End If
                End If
            ElseIf (intYear >= 1966) Then
                If (intDay = 15) Then
                    strHoliday = "Respect for the Aged Day"
                End If
            End If
        End If

' // October //
    Case 10
        strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
        Select Case intYear
          Case Is >= 2022
            If (strWeek = "22") Then  '2nd Monday(2)
                strHoliday = "Sports Day'rename since 2020
            End If
          Case 2020 , 2021
            ' "Sports Day" moved to July 23th by the Olympic Special Measures Law in 2021.
            ' "Sports Day" moved to July 24th by the Olympic Special Measures Law in 2020.
          Case Is >= 2000
            If (strWeek = "22") Then  '2nd Monday(2)
                strHoliday = "Health and Sports Day"
            ElseIf (ChkDate = cstCeremonyEnthronement_Naruhito) Then    ' 2019 Oct. 22 (HIH Crown Prince Naruhito)
                prvHoliday = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
            End If
          Case Is >= 1966
            If (intDay = 10) Then
                strHoliday = "Health and Sports Day"
            End If
          Case Else
        End Select

' // November //
    Case 11
        If (intDay = 3) Then
            strHoliday = "National Culture Day"
        ElseIf (intDay = 23) Then
            strHoliday = "Labor Thanksgiving Day"
        ElseIf (ChkDate = cstCeremonyEnthronement) Then  ' [1990 Nov.12th]
            strHoliday = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
        End If

' // December //
    Case 12
        If (intDay = 23) Then
            If ((intYear >= 1989) And (intYear <= 2018)) Then
                strHoliday = "Emperor's Birthday' Birthday of Emperor Heisei.
            End If
        End If
    End Select

'--- Judgment of "Holiday in Lieu" ---
    If (strHoliday = "") Then
        If (Weekday(ChkDate) = cstMonday) Then
            ' In the day except Monday, it doesn't need a judgement in [Holiday in Lieu]
            ' In May 6th ( Tuesday, Wednesday ), it has judged above already.
            ' In May 6th ( Monday ), it judges here.
            If (ChkDate >= cstEnforcementDate_HolidayInLieu) Then    ' [1973 Apr.12th]
                If (JpnHolidayName(ChkDate - 1) <> "") Then  '[Recursive Call]
                    ' When the day before ChkDate is Holiday and Sunday,
                    ' ChkDate is [Holiday in Lieu]

                    JpnHolidayName = "Holiday in Lieu"
                Else
                    JpnHolidayName = ""
                End If
            Else
                JpnHolidayName = ""
            End If
        Else
            JpnHolidayName = ""
        End If
    Else
        JpnHolidayName = strHoliday
    End If
End Function

' (Note) VernalEquinox and AutumnalEquinox
' [ Year=1948 to 1979 ]
' VernalEquinox = [20.8357 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
' AutumnalEquinox = [23.2588 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
' [A] is the gauss symbol. The integer which doesn't over A. [-5 / 4] = [-1.25]= -2
' VB or VBA : Int(-5/4)= -2  Fix(-5/4)= -1
' C language : Int(-5/4)= -1
' Formula when VB or VBA using [Fix] is Fix((ChkYear - 1983) / 4) in from 1948 to 1979.
' Formula for C language is  Int((ChkYear - 1983) / 4) in from 1948 to 1979.



'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/




The following is macro for the test.
  Sub Test
  dim MyDate as date
  dim dtmStart as date
  dim dtmEnd as date
  dim strwk1 as string
  dim strwk2 as string
  const cstYear as integer = 2005
    dtmStart = dateserial(cstYear,1,1)
    dtmEnd = dateserial(cstYear,12,31)
    for MyDate = dtmStart to dtmEnd step 1
        strwk1 = JpnHolidayName(MyDate)
        if (strwk1 <> "") then
            strwk2 = strwk2 & Chr(13) & Format(MyDate,"yyyy/mm/dd") & "(" & _
                      Choose(Weekday(MyDate),"Sun","Mon","Tue","Wed","Thu","Fri","Sat") & _
                      ") , " & strwk1
        end if
    next MyDate
    Beep
    MsgBox strwk2
  End Sub



[ Link to here ]


[ The holiday judgment macro for  JavaScript ]
    2005 May 26th    It changed "Showa's Day" into "Showa Day".
    2008 Oct 29th    It was corrected that there was no var specification.
    2011 Mar 20th   I revised it to evade "FireFox TraceMonkey bug". 
    2014 May 29th    "Mountain Day" is added.
    2015 July 11th   I cancel the limit of the range on a date to be able to treat it
                              before "1 Jan. 1970" after JavaScript1.3 .
    2018 Feb. 15th    "the change of the Emperor's Birthday" is added.
    2018 June 21th    Renamed "Health and Sports Day"  ( to "Sports Day" )  and
                                  "Movement of public holidays" only in 2020 by the Olympic Special Measures Law.
    2018 Dec. 8th    It corresponds to the revision of the following holidays.
                                  2019 May 1st   "The Enthronement day of HIH Crown Prince Naruhito"
                                  2019 Apr. 30th & May 2nd   "Citizen's Holiday" to be sandwiched on two holidays
                                  2019 Oct. 22th   "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
    2018 Dec. 11th    Add restriction clause of argument (see comment at the beginning of source code)
    2020 Nov. 28th    "Movement of public holidays" only in 2021 by the Olympic Special Measures Law.



    JavaScript file : JapanHolidayChk_Eng.js

    It transplanted this holiday judgment macro from the VBA macro for [JavaScript].
    When adding conditions such as judging the weekend and so on together,
    it refers to "The attention point when doing a holiday judgment".
    As for the contents in the holiday, it refers to "about the holiday in Japan".


----------------------------------------------------------------------------------------
 


<!--
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/
//_/    ==== Japanese Holiday Check Function ( JavaScript , Update: 2020 Nov. 28 ) ====
//_/
//_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
//_/  ( AddinBox  http://addinbox.sakura.ne.jp/index.htm )
//_/  (  Old Site  http://www.h3.dion.ne.jp/~sakatsu/index.htm )
//_/
//_/  It transplanted this holiday judgment macro
//_/  from the VBA macro for [JavaScript].
//_/
//_/  The holiday which was defined by the present holiday law can be won in this macro.
//_/  The holidays changes supported by this macro are as follows.
//_/  ( a ) Change date of "Emperorfs Birthday" enforced in 2019. ( 23th Dec. to 23th Feb. )
//_/          (Note: There is no "Emperorfs Birthday" in 2019.)
//_/  ( b ) May 1st 2019 is "The Enthronement day of HIH Crown Prince Naruhito".
//_/          April 30th and May 2nd 2019 are holidays because they are sandwiched between national holidays.
//_/          In addition, April 30th is Emperor Heiseifs abdication day.
//_/  ( c ) Oct. 22th 2019 is "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"
//_/  ( d ) Renamed "Health and Sports Day" enforced in 2020. ( to "Sports Day" )
//_/  ( e ) "Movement of public holidays" only in 2020 by the Olympic Special Measures Law.
//_/          Marine Day : 20th July ( 3rd Monday ) to 23th July
//_/          Sports Day : 12th Oct. ( 2nd momnday ) to 24th July
//_/          Mountain Day : 11th Aug. to 10th Aug.
//_/  ( f ) "Movement of public holidays" only in 2021 by the Olympic postponement.
//_/          Marine Day : 19th July ( 3rd Monday ) to 22th July
//_/          Sports Day : 11th Oct. ( 2nd Monday ) to 23th July
//_/          Mountain Day : 11th Aug. to 8th Aug.
//_/
//_/  This logic made to improve a response the most priority
//_/  and designed that it is possible to let out a result by
//_/  " the execution of the condition judgment " with little
//_/  number of times as far as it is possible for its purpose.
//_/  It is for its purpose that it adopts the style which doesn't
//_/  use [And/Or] operator.
//_/
//_/  (*1) When quoting this macro, always together quote
//_/          the comment which is mentioned to here.
//_/
//_/  (*2) It prohibits to quote this whole macro code in the
//_/          other site and to carry. When introducing this macro,
//_/          do following URL only to mention it.
//_/      [ http://addinbox.sakura.ne.jp/holiday_logic_English.htm ]
//_/
//_/  ---- Argument restrictions ----
//_/  In the argument of ktHolidayName, write the date format (YYYY/M/D) of the slash delimiter.
//_/  Date format (YYYY-MM-DD) with hyphen delimiter is not allowed.
//_/  ( Reason )
//_/  The date constant of YYYY-MM-DD does not match the date constant (time=0:0:0) in ktHolidayName
//_/  because it is converted to UTC by [new date] (time difference is reflected).
//_/  In Japan, the time of [+9:00] is attached.
//_/  In the American West Coast [-8:00] will be the previous day's date.
//_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//
// 29 Oct 2008
//    It was corrected that there was no var specification.
//
// 29 May 2014
//    Holiday law revision of "Mountain Day"
//
// 11 July 2015
//    I cancel the limit of the range on a date to be able to treat it
//    before "1 Jan. 1970" after JavaScript1.3 .
//
// 15 Feb 2018
//    Holiday law revision of "the change of the Emperor's Birthday"
//
// 21 June 2018
//    [ Renamed "Health and Sports Day" ] and
//    [ "Movement of public holidays" only in 2020 by the Olympic Special Measures Law. ]
//
// 8 Dec. 2018
//    [May 1st 2019 : "The Enthronement day of HIH Crown Prince Naruhito"]
//    [April 30th and May 2nd 2019 : They are holidays because they are sandwiched between national holidays.]
//    [Oct. 22th 2019 is "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)"]
//
// 11 Dec. 2018
//    Argument restrictions added to head comment
//
// 28 Nov. 2020
///    [ "Movement of public holidays" only in 2021 by the Olympic Special Measures Law. ]



var MONDAY = 1;
var TUESDAY = 2;
var WEDNESDAY = 3;

// Month is [0-11] in JavaScript.

// Date of Enforcement of the Holidays Law #1948 July 20#
var cstEnforcementDate_Holiday_Law = new Date(1948,6,20);

// The Rite of Wedding of HIH Crown Prince Akihito #1959 April 10#
var cstWeddingHIH_Akihito = new Date(1959,3,10);

// The Funeral Ceremony of Emperor Showa. #1989 February 24#
var cstFuneralCeremony_Showa = new Date(1989,1,24);

// The Rite of Wedding of HIH Crown Prince Naruhito #1993 June 9#
var cstWeddingHIH_Naruhito = new Date(1993,5,9);

// The Ceremony of the Enthronement of His Majesty the Emperor
// (at the Seiden) #1990 November 12#
var cstCeremonyEnthronement = new Date(1990,10,12);

// Date of Enforcement of Holidays in Lieu #1973 April 12#
var cstEnforcementDate_HolidayInLieu = new Date(1973,3,12);


// Emperor Heisei's abdication day #2019 April 30#
// It is a holiday because it is sandwiched between national holidays.
var cstEmperorHeisei_AbdicationDay = new Date(2019,3,30);

// The Enthronement day of HIH Crown Prince Naruhito #2019 May 1#
var cstEnthronementDay_Naruhito = new Date (2019,4,1);

// It is a holiday because it is sandwiched between national holidays. #2019 May 2#
var cst2019_May2nd = new Date(2019,4,2);

// The Ceremony of the Enthronement of His Majesty the Emperor
// (at the Seiden) #2019 Octorber 22#
var cstCeremonyEnthronement_Naruhito = new Date(2019,9,22);


//===============================================================
// [prmDate] is the date-string of "yyyy/m/d" form.

function ktHolidayName(prmDate)
{
  var MyDate = new Date(prmDate);
  var HolidayName = prvHolidayChk(MyDate);
  var YesterDay;
  var HolidayName_ret;

  if (HolidayName == "") {
      if (MyDate.getDay() == MONDAY) {
          // In the day except Monday, it doesn't need a judgement in [Holiday in Lieu]
          // In May 6th ( Tuesday, Wednesday ), it has judged in prvHolidayChk.
          // In May 6th ( Monday ), it judges here.

          if (MyDate.getTime() >= cstEnforcementDate_HolidayInLieu.getTime()) {  // [1973 Apr.12th]
              YesterDay = new Date(MyDate.getFullYear(),
                                    MyDate.getMonth(),(MyDate.getDate()-1));
              HolidayName = prvHolidayChk(YesterDay);
              if (HolidayName != "") {
                  HolidayName_ret = "Holiday in Lieu";
              } else {
                  HolidayName_ret = "";
              }
          } else {
              HolidayName_ret = "";
          }
      } else {
          HolidayName_ret = "";
      }
  } else {
      HolidayName_ret = HolidayName;
  }

  return HolidayName_ret;
}

//===============================================================
// [MyDate] is the date-object.

function prvHolidayChk(MyDate)
{
  var MyYear = MyDate.getFullYear();
  var MyMonth = MyDate.getMonth() + 1;    // MyMonth:1`12
  var MyDay = MyDate.getDate();
  var NumberOfWeek;
  var MyAutumnEquinox;
  var Result = "";

 if (MyDate.getTime() < cstEnforcementDate_Holiday_Law.getTime()) {  // [1948 Jul.20th]
      return ""; // before Date of Enforcement of the Holidays Law
 } else;

  switch (MyMonth) {
// January //
  case 1:
      if (MyDay == 1) {
          Result = "New Year's Day";
      } else {
          if (MyYear >= 2000) {
              NumberOfWeek = Math.floor((MyDay - 1) / 7) + 1;
              if ((NumberOfWeek == 2) && (MyDate.getDay() == MONDAY)) {
                  Result = "Coming of Age Day";  // 2nd Monday
              } else;
          } else {
              if (MyDay == 15) {
                  Result = "Coming of Age Day";
              } else;
          }
      }
      break;

// February //
  case 2:
      if (MyDay == 11) {
          if (MyYear >= 1967) {
              Result = "National Foundation Day";
          } else;
      } else {
          if (MyDay == 23) {
              if (MyYear >= 2020) {
                  Result = "Emperor's Birthday";
              } else;
          } else {
              if (MyDate.getTime() == cstFuneralCeremony_Showa.getTime()) {  // [1989 Feb.24th]
                  Result = "The Funeral Ceremony of Emperor Showa.";
              } else;
          }
      }
      break;

// March //
  case 3:
      if (MyDay == prvVernalEquinox(MyYear)) {
          // Because 99 returns except the range from 1948 to 2150,
          // it doesn't become an equal.

          Result = "Vernal Equinox Day";
      } else;
      break;

// April //
  case 4:
      if (MyDay == 29) {
          if (MyYear >= 2007) {
              Result = "Showa Day";
          } else {
              if (MyYear >= 1989) {
                  Result = "Greenery Day";
              } else {
                  Result = "Emperor's Birthday";  // Birthday of Emperor Showa.
              }
          }
      } else {
          if (MyDate.getTime() == cstEmperorHeisei_AbdicationDay.getTime()) {  // [2019 Apr. 30th]
              // It is sandwiched between national holidays (April 29 and May 1).
              Result = "Citizen's Holiday";  // Emperor Heisei's abdication day
          } else {
              if (MyDate.getTime() == cstWeddingHIH_Akihito.getTime()) {
                  Result = "The Rite of Wedding of HIH Crown Prince Akihito";  // [1959 Apr.10th]
              } else;
          }
      }
      break;

// May //
  case 5:
      switch ( MyDay ) {
        case 3:  // May 3rd
          Result = "Constitution Memorial Day";
          break;
        case 4:  // May 4th
          if (MyYear >= 2007) {
              Result = "Greenery Day";
          } else {
              if (MyYear >= 1986) {
                  if (MyDate.getDay() > MONDAY) {  // After Tuesday (Tue - Sat)
                      // It is mere Sunday ,when [May 4th] is Sunday
                      // It is Holiday in lieu of [Constitution Memorial Day] ,when [May 4th] is Monday
                      Result = "Citizen's Holiday";
                  } else;
              } else;
          }
          break;
        case 5:  // May 5th
          Result = "Children's Day";
          break;
        case 6:  // May 6th
          if (MyYear >= 2007) {
              if ((MyDate.getDay() == TUESDAY) || (MyDate.getDay() == WEDNESDAY)) {
                  // When May 3rd or May 4th becomes on Sunday, it judges here.
                  Result = "Holiday in Lieu";
              } else;
          } else;
          break;
        default:
          if (MyYear == 2019) {
              if (MyDate.getTime() == cstEnthronementDay_Naruhito.getTime()) {  // [2019 May 1st]
                  Result = "The Enthronement day of HIH Crown Prince Naruhito";
              } else {
                  if (MyDate.getTime() == cst2019_May2nd.getTime()) {  // [2019 May 2nd]
                      // It is sandwiched between national holidays (May 1 and May 3).
                      Result = "Citizen's Holiday";
                  } else;
              }
          } else;
      }
      break;

// June //
  case 6:
      if (MyDate.getTime() == cstWeddingHIH_Naruhito.getTime()) {  // [1993 Jun.9th]
          Result = "The Rite of Wedding of HIH Crown Prince Naruhito";
      } else;
      break;

// July //
  case 7:
      NumberOfWeek = Math.floor((MyDay - 1) / 7) + 1;
      if (MyYear >= 2022) {
          if ((NumberOfWeek == 3) && (MyDate.getDay() == MONDAY)) {  // 3rd Monday
              Result = "Marine Day";
          } else;
      } else {
          if (MyYear == 2021) {
              // "Marine Day" moved to July 22th, "Sports Day" moved to July 23th
              // by the Olympic Special Measures Law in 2021.
              if (MyDay == 22) {
                  Result = "Marine Day";
              } else {
                  if (MyDay == 23) {
                      Result = "Sports Day";
                  } else;
              }
          } else {
              if (MyYear == 2020) {
                  // "Marine Day" moved to July 23th, "Sports Day" moved to July 24th
                  // by the Olympic Special Measures Law in 2020.
                  if (MyDay == 23) {
                      Result = "Marine Day";
                  } else {
                      if (MyDay == 24) {
                          Result = "Sports Day";
                      } else;
                  }
              } else {
                  if (MyYear >= 2003) {
                      if ((NumberOfWeek == 3) && (MyDate.getDay() == MONDAY)) {  // 3rd Monday
                          Result = "Marine Day";
                      } else;
                  } else {
                      if (MyYear >= 1996) {
                          if (MyDay == 20) {
                              Result = "Marine Day";
                          } else;
                      } else;
                  }
              }
          }
      }
      break;

// August //
  case 8:
      if (MyYear >= 2022) {
          if (MyDay == 11) {
              Result = "Mountain Day";
          } else;
      } else {
          if (MyYear == 2021) {
              // "Mountain Day" moved to August 8th by the Olympic Special Measures Law in 2020.
              if (MyDay == 8) {
                  Result = "Mountain Day";
              } else;
          } else {
              if (MyYear == 2020) {
                  // "Mountain Day" moved to August 10th by the Olympic Special Measures Law in 2020.
                  if (MyDay == 10) {
                      Result = "Mountain Day";
                  } else;
              } else {
                  if (MyYear >= 2016) {
                      if (MyDay == 11) {
                          Result = "Mountain Day";
                      } else;
                  } else;
              }
          }
      }
      break;

// September //
  case 9:
      // 3rd Monday(15th to 21th) and Autumnal Equinox day(22th to 24th) never agree
      MyAutumnEquinox = prvAutumnalEquinox(MyYear);
      // Because 99 returns except the range from 1948 to 2150,
      // it doesn't become an equal.

      if (MyDay == MyAutumnEquinox) {
          Result = "Autumnal Equinox Day";
      } else {
          if (MyYear >= 2003) {
              NumberOfWeek = Math.floor((MyDay - 1) / 7) + 1;
              if ((NumberOfWeek == 3) && (MyDate.getDay() == MONDAY)) {  // 3rd Monday
                  Result = "Respect for the Aged Day";
              } else {
                  if (MyDate.getDay() == TUESDAY) {
                      if (MyDay == (MyAutumnEquinox - 1)) {
                      // Monday(3rd) : Respect for the Aged Day
                      // Tuesday     : Citizen's Holiday (between two Holidays)
                      // Wednesday   : In case, Autumnal Equinox Day

                          Result = "Citizen's Holiday";
                      } else;
                  } else;
              }
          } else {
              if (MyYear >= 1966) {
                  if (MyDay == 15) {
                      Result = "Respect for the Aged Day";
                  } else;
              } else;
          }
      }
      break;

// October //
  case 10:
      NumberOfWeek = Math.floor(( MyDay - 1) / 7) + 1;
      if (MyYear >= 2022) {
          if ((NumberOfWeek == 2) && (MyDate.getDay() == MONDAY)) {  // 2nd Monday
              Result = "Sports Day";  // rename since 2020
          } else;
      } else {
          if ((MyYear == 2021) || (MyYear == 2020)) {
              // "Sports Day" moved to July 23th by the Olympic Special Measures Law in 2021.
              // "Sports Day" moved to July 24th by the Olympic Special Measures Law in 2020.
          } else {
              if (MyYear >= 2000) {
                  if ((NumberOfWeek == 2) && (MyDate.getDay() == MONDAY)) {  // 2nd Monday
                      Result = "Health and Sports Day";
                  } else {
                      if (MyDate.getTime() == cstCeremonyEnthronement_Naruhito.getTime()) {  // [2019 Oct. 22th]
                          // HIH Crown Prince Naruhito
                          Result = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)";
                      } else;
                  }
              } else {
                  if (MyYear >= 1966) {
                      if (MyDay == 10) {
                          Result = "Health and Sports Day";
                      } else;
                  } else;
              }
          }
      }
      break;

// November //
  case 11:
      if (MyDay == 3) {
          Result = "National Culture Day";
      } else {
          if (MyDay == 23) {
              Result = "Labor Thanksgiving Day";
          } else {
              if (MyDate.getTime() == cstCeremonyEnthronement.getTime()) {  // [1990 Nov.12th]
                  Result = "The Ceremony of the Enthronement of His Majesty the Emperor (at the Seiden)";
              } else;
          }
      }
      break;

// December //
  case 12:
      if (MyDay == 23) {
          if ((MyYear >= 1989) && (MyYear <= 2018)) {
              Result = "Emperor's Birthday";  // Birthday of Emperor Heisei.
          } else;
      } else;
      break;
  }

  return Result;
}

//===================================================================
// This simple computation formula of VernalEquinox and AutumnalEquinox is presented by
// Japan Coast Guard / Hydrographic and Oceanographic Department
// [ Sin Koyomi Benrichou (ISBN4-7699-0700-1) ]

function prvVernalEquinox(MyYear)
{
  var VernalEquinox_ret;

  if (MyYear <= 1947) {
      VernalEquinox_ret = 99;    // before Date of Enforcement of the Holidays Law
  } else {
      if (MyYear <= 1979) {
          // The Math.floor function is equal to [ the Int function of VBA ]
          VernalEquinox_ret = Math.floor(20.8357 +
            (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
      } else {
          if (MyYear <= 2099) {
              VernalEquinox_ret = Math.floor(20.8431 +
                (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
          } else {
              if (MyYear <= 2150) {
                  VernalEquinox_ret = Math.floor(21.851 +
                    (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
              } else {
                  VernalEquinox_ret = 99;    // VernalEquinoxDay is unknown after 2151
              }
          }
      }
  }
  return VernalEquinox_ret;
}

//=====================================================================
function prvAutumnalEquinox(MyYear)
{
  var AutumnEquinox_ret;

  if (MyYear <= 1947) {
      AutumnalEquinox_ret = 99; // before Date of Enforcement of the Holidays Law
  } else {
      if (MyYear <= 1979) {
          // The Math.floor function is equal to [ the Int function of VBA ]
          AutumnalEquinox_ret = Math.floor(23.2588 +
            (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
      } else {
          if (MyYear <= 2099) {
              AutumnalEquinox_ret = Math.floor(23.2488 +
                (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
          } else {
              if (MyYear <= 2150) {
                  AutumnalEquinox_ret = Math.floor(24.2488 +
                    (0.242194 * (MyYear - 1980)) - Math.floor((MyYear - 1980) / 4));
              } else {
                  AutumnalEquinox_ret = 99;    // AutumnalEquinoxDay is unknown after 2151
              }
          }
      }
  }
  return AutumnalEquinox_ret;
}

// (Note) VernalEquinox and AutumnalEquinox
// [ Year=1948 to 1979 ]
// VernalEquinox = [20.8357 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
// AutumnalEquinox = [23.2588 + (0.242194 * (ChkYear - 1980)) - [(ChkYear - 1980) / 4] ]
// [A] is the gauss symbol. The integer which doesn't over A. [-5 / 4] = [-1.25]= -2
// VB or VBA : Int(-5/4)= -2  Fix(-5/4)= -1
// C language : Int(-5/4)= -1
// Formula when VB or VBA using [Fix] is Fix((ChkYear - 1983) / 4) in from 1948 to 1979.
// Formula for C language is  Int((ChkYear - 1983) / 4) in from 1948 to 1979.

//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/  CopyRight(C) K.Tsunoda(AddinBox) 2005 All Rights Reserved.
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

-->




The following is script for the test.

<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
    [ It pastes above-mentioned JavaScript code on this place. ]

var WeekName = new Array(7);
WeekName[0] = "Sun";
WeekName[1] = "Mon";
WeekName[2] = "Tue";
WeekName[3] = "Wed";
WeekName[4] = "Thu";
WeekName[5] = "Fri";
WeekName[6] = "Sat";

function getWeekName(Week) {  // change week-num to week-name
  return WeekName[Week];
}

function sample1() {
  document.Form1.TextBox2.value =
              ktHolidayName(document.Form1.TextBox1.value);
}

function sample2() {
  var OneDay = 24 * 60 * 60 * 1000;    // The 1 day millisecond
  // Month is [0-11] in JavaScript
  var FirstDate = new Date(2017,0,1);      // 2017 Jan.1st
  var LastDate = new Date(2030,11,31);  // 2030 Dec.31th
  var wkDate = FirstDate;
  var strDate;
  var HName;

  DW1=window.open("","Holiday_Name_List","menubar=yes,location=no,scrollbars=yes,status=yes");
  DW1.document.open();
  DW1.document.write('<HTML>\n<HEAD>\n<TITLE>Holiday_Name_List</TITLE>\n</HEAD>\n<BODY>\n<P>\n');

  while (wkDate.getTime() <= LastDate.getTime()) {
    strDate = wkDate.getFullYear() + "/" +
                    (wkDate.getMonth() + 1) + "/" + wkDate.getDate();
    HName = ktHolidayName(strDate);
    if (HName != "") {
        DW1.document.write(strDate + " (" +
              getWeekName(wkDate.getDay()) + ") " + HName + "<BR>\n");
    }
    wkDate.setTime(wkDate.getTime() + OneDay);
  }

  DW1.document.write('</P>\n</BODY>\n</HTML>');
  DW1.document.close();

}
//-->
</SCRIPT>
</HEAD>
<BODY>
It clicks the display button after typing a date in the yyyy/mm/dd form.<BR>
<FORM name="Form1">
<INPUT size="20" type="text" name="TextBox1">
<INPUT type="button" name="Button1" value="-- > Display Holiday Name -- >" onclick="sample1();">
<INPUT size="60" type="text" name="TextBox2"><BR><BR>
It displays a holiday list in the period of 2017 Jan.1st - 2030 Dec.31th.<BR>
<INPUT type="button" name="Button2"
  value="Holiday List in 2017 - 2030" onclick="sample2();">
</FORM>
</BODY>
</HTML>


==========================================================
It clicks the display button after typing a date in the yyyy/mm/dd form.


It displays a holiday list in the period of 2017 Jan.1st - 2030 Dec.31th.






[ AddinBox Home(Jpn.) ]  [ English Home ]  [ Holiday Macro(Jpn.) ]

AddinBox ( K.Tsunoda in Japan ) CopyRight(C) 2001 Allrights Reserved.