AddinBox(Title_Logo)

 
    The holiday in Japan  &
        The holiday judgment logic

                                                                                              (Update: 2015 July 11   JST )
                                                                                              (Update: 2016 March 5   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 revision ( so-called " Mountain Day " ) of the holiday law to enforce from
2016 was promulgated on May 23th, 2014. The following contents have reflected
the revision.


-- Language -- -- Editor -- -- Release --  
The attention point when doing a holiday judgment
The usage example ( Bank_Workday / Bank_Networkdays )
VB/VBA AddinBox(K.Tsunoda) Update:2014/5/29 2005 Apr.17th  
OOoBasic AddinBox(K.Tsunoda) Update:2014/5/29 2005 Apr.17th  
JavaScript AddinBox(K.Tsunoda) Update:2015/7/11 2005 May 5th  
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
 Vernal Equinox Day VernalEquinox 1948 Jul.20th left 1949
 Emperor's Birthday
      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
 Mountain Day Aug. 11th 2014 May.30th 2016 Jan. 1st 2016
 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 Oct.10th 1966 Jun.25th left 1966
Oct.[2nd Monday] 1998 Oct.21th 2000 Jan.1st 2000
 National Culture Day Nov.3rd 1948 Jul.20th left 1948
 Labor Thanksgiving Day Nov.23th 1948 Jul.20th left 1948
 Emperor's Birthday Dec.23th 1989 Feb.17th left 1989
---- 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
 [ 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" ) ]
    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

--- 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  Now (H1 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
  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




[ The holiday judgment macro for VB and VBA ]    (Update: 2014 May 29th )
    (2005 May 26th    It changed "Showa's Day" into "Showa Day".)
    (2014 May 29th    "Mountain Day" is added.)

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 ====
'_/
'_/  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 revision which is enforced
'_/  from 2016 is reflected in this code. ).
'_/
'_/  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#

    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 (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
        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
                    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
        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
        If (intYear >= 2003) Then
            strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
            If (strWeek = "32") Then  ' 3rd Monday
                prvHoliday = "Marine Day"
            End If
        ElseIf (intYear >= 1996) Then
            If (intDay = 20) Then
                prvHoliday = "Marine Day"
            End If
        End If
' // August //
    Case 8
        If (intDay = 11) Then
            If (intYear >= 2016) Then
                prvHoliday = "Mountain Day"
            End If
        End If
' // 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
        If (intYear >= 2000) Then
            strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
            If (strWeek = "22") Then  ' 2nd Monday
                prvHoliday = "Health and Sports Day"
            End If
        ElseIf (intYear >= 1966) Then
            If (intDay = 10) Then
                prvHoliday = "Health and Sports Day"
            End If
        End If
' // 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) 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.
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/






[ The holiday judgment macro for OpenOffice.org Basic ]    (Update: 2014 May 29th )
    (2005 May 26th    It changed "Showa's Day" into "Showa Day".)
    (2014 May 29th    "Mountain Day" is added.)

    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 ====
'_/
'_/  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].
'_/
'_/  The holiday which was defined by the present holiday law
'_/  can be won in this macro ( The revision which is enforced
'_/  from 2016 is reflected in this code.).
'_/
'_/  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

    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 (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
        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
                    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
        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
        If (intYear >= 2003) Then
            strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
            If (strWeek = "32") Then  ' 3rd Monday
                strHoliday = "Marine Day"
            End If
        ElseIf (intYear >= 1996) Then
            If (intDay = 20) Then
                strHoliday = "Marine Day"
            End If
        End If
' // August //
    Case 8
        If (intDay = 11) Then
            If (intYear >= 2016) Then
                strHoliday = "Mountain Day"
            End If
        End If
' // 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
        If (intYear >= 2000) Then
            strWeek = (((intDay - 1) \ 7) + 1) & Weekday(ChkDate)
            If (strWeek = "22") Then    ' 2nd Monday
                strHoliday = "Health and Sports Day"
            End If
        ElseIf (intYear >= 1966) Then
            If (intDay = 10) Then
                strHoliday = "Health and Sports Day"
            End If
        End If
' // 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) 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





[ The holiday judgment macro for JavaScript ]    ( Update: 2015 July 11th )
    (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 .)



    JavaScript file : JapanHolidayChk_Eng.js ( [ switch ] statement version )
        [ if ] statement version : JapanHolidayChk_Eng_IF.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 ====
//_/
//_/ 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 ( It is reflected until revision of
//_/  the execution in 2016 ).
//_/
//_/  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 ]
//_/ 
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//
// 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 .



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);


//===============================================================
// [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 (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() == 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) {
                      // 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;
      }
      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:
      if (MyYear >= 2003) {
          NumberOfWeek = Math.floor((MyDay - 1) / 7) + 1;
          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 (MyDay == 11) {
          if (MyYear >= 2016) {
              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:
      if (MyYear >= 2000) {
          NumberOfWeek = Math.floor(( MyDay - 1) / 7) + 1;
          if ((NumberOfWeek == 2) && (MyDate.getDay() == MONDAY)) {  // 2nd Monday
              Result = "Health and Sports Day";
          } 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) {
              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(2011,0,1);      // 2011 Jan.1st
  var LastDate = new Date(2020,11,31);  // 2020 Dec.31th
  var wkDate = FirstDate;
  var strDate;
  var HName;

  while (wkDate.getTime() <= LastDate.getTime()) {
    strDate = wkDate.getFullYear() + "/" +
                    (wkDate.getMonth() + 1) + "/" + wkDate.getDate();
    HName = ktHolidayName(strDate);
    if (HName != "") {
        document.write(strDate + " (" +
              getWeekName(wkDate.getDay()) + ") " + HName + "<BR>");
    }
    wkDate.setTime(wkDate.getTime() + OneDay);
  }
}
//-->
</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 2005 Jan.1st - 2010 Dec.31th.<BR>
<INPUT type="button" name="Button2"
  value="Holiday List in 2005 - 2010" 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 2011 Jan.1st - 2020 Dec.31th.







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

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