Determine Dates for Holidays

From HotDocs Wiki

Jump to: navigation, search

You can write computations to determine exact dates for holidays in any given year. For example, if you want to include a list of company holidays for the next year, you can write a computation to list the name of each holiday and its date.

Holidays that occur on the same date each year are relatively simple to determine. Computations to calculate fixed holiday dates simply require a year, which they use along with the known months and days to return full dates for those holidays. Other holidays are a little more complicated because they change from year to year. Thanksgiving Day, for example, occurs on the fourth Thursday in November (in the United States). For these "floating" holidays, the computations must be scripted to calculate the correct date given the known rules. Easter Sunday is even more complicated because it is the first Sunday after the Paschal Full Moon (PFM) date for the year. (Calculating the PFM date can be very complicated.)

Contents

Examples

In the following computations:

Year is a Number variable for the year when you want to find the date of a holiday. If you want dates for the current year, you can use SET Year TO YEAR OF( TODAY ) to automatically set this variable, or you could just use YEAR OF( TODAY ) in place of Year in the computations.

Century is temporary Number variable used in the Easter date computation (indicates the century).

Temp Var is a temporary Number variable used in the Easter date computation.

Full Moon is a temporary Number variable used in the Easter date computation when calculating the Paschal Full Moon date.

Script for Fixed Dates

New Year's Day (January 1)

DATE OF( 1, 1, Year )

Valentine's Day (February 14)

DATE OF( 14, 2, Year )

Independence Day (July 4)

DATE OF( 4, 7, Year )

Christmas Day (December 25)

DATE OF( 25, 12, Year )

Script for Floating Dates

Note: Many of these computations can be shortened or simplified using the WHILE expression, which is available only in HotDocs 6.2 and higher. Examples with and without the WHILE expression are included below.

Martin Luther King, Jr., Day (Third Monday in January)

//All versions of HotDocs
DATE OF( 1, 1, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 1
 RESULT + 7 DAYS
END IF
RESULT + 14 DAYS
 
//HotDocs 6.2 and later
DATE OF( 1, 1, Year )
WHILE DAY OF WEEK ( RESULT ) != 2
 RESULT + 1 DAY
END WHILE
RESULT + 14 DAYS

President's Day (Third Monday in February)

//All versions of HotDocs
DATE OF( 1, 2, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 2
RESULT + 7 DAYS
END IF
RESULT + 14 DAYS
 
//HotDocs 6.2 and later
DATE OF( 1, 2, Year )
WHILE DAY OF WEEK ( RESULT ) != 2
RESULT + 1 DAY
END WHILE
RESULT + 14 DAYS

Easter (First Sunday after the Paschal Full Moon (PFM) date)

//All versions of HotDocs
SET Century TO TRUNCATE( Year / 100, 0 )
SET Temp Var TO TRUNCATE( ( Century - 15) / 2, 0 ) + 202
SET Temp Var TO Temp Var - 11 * REMAINDER( Year, 19 )
IF Century = 21 OR Century = 24 OR Century = 25 OR ( Century >= 27 AND Century <=  32 ) OR Century = 34 OR Century = 35 OR Century = 38
 SET Temp Var TO Temp Var - 1
ELSE IF Century = 33 OR Century = 36 OR Century = 37 OR Century = 39 OR Century =  40
 SET Temp Var TO Temp Var - 2
END IF
SET Temp Var TO REMAINDER( Temp Var, 30 )
SET Full Moon TO Temp Var + 21
IF Temp Var = 29
 SET Full Moon TO Full Moon - 1
END IF
IF Temp Var = 28 AND REMAINDER( Year, 19 ) > 10
 SET Full Moon TO Full Moon - 1
END IF
IF Full Moon > 31
 SET Full Moon TO Full Moon - 31
 DATE OF( Full Moon, 4, Year ) + 1 DAY
ELSE
 DATE OF( Full Moon, 3, Year ) + 1 DAY
END IF
IF DAY OF WEEK( RESULT ) != 1
 RESULT + ( 8 - DAY OF WEEK( RESULT ) ) DAYS
END IF
 
//HotDocs 6.2 and later
SET Century TO TRUNCATE( Year / 100, 0 )
SET Temp Var TO TRUNCATE( ( Century - 15) / 2, 0 ) + 202
SET Temp Var TO Temp Var - 11 * REMAINDER( Year, 19 )
IF Century = 21 OR Century = 24 OR Century = 25 OR ( Century >= 27 AND Century <=  32 ) OR Century = 34 OR Century = 35 OR Century = 38
 SET Temp Var TO Temp Var - 1
ELSE IF Century = 33 OR Century = 36 OR Century = 37 OR Century = 39 OR Century =  40
 SET Temp Var TO Temp Var - 2
END IF
SET Temp Var TO REMAINDER( Temp Var, 30 )
SET Full Moon TO Temp Var + 21
IF Temp Var = 29
 DECREMENT Full Moon
END IF
IF Temp Var = 28 AND REMAINDER( Year, 19 ) > 10
 DECREMENT Full Moon
END IF
IF Full Moon > 31
 SET Full Moon TO Full Moon - 31
 DATE OF( Full Moon, 4, Year ) + 1 DAY
ELSE
 DATE OF( Full Moon, 3, Year ) + 1 DAY
END IF
WHILE DAY OF WEEK( RESULT ) != 1
 RESULT + 1 DAY
END WHILE

Memorial Day (Last Monday in May)

//All versions of HotDocs
DATE OF( 1, 6, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 5
 RESULT - 7 DAYS
END IF
 
//HotDocs 6.2 and later
DATE OF( 31, 5, Year )
WHILE DAY OF WEEK( RESULT ) != 2
 RESULT - 1 DAY
END WHILE

Labor Day (First Monday in September)

//All versions of HotDocs
DATE OF( 1, 9, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 9
 RESULT + 7 DAYS
END IF
 
//HotDocs 6.2 and later
DATE OF( 1, 9, Year )
WHILE DAY OF WEEK ( RESULT ) != 2
  RESULT + 1 DAY
END WHILE

Columbus Day (Second Monday in October)

//All versions of HotDocs
DATE OF( 1, 10, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 10
  RESULT + 14 DAYS
ELSE
  RESULT + 7 DAYS
END IF
 
//HotDocs 6.2 and later
DATE OF( 1, 10, Year )
WHILE DAY OF WEEK ( RESULT ) != 2
  RESULT + 1 DAY
END WHILE
RESULT + 7 DAYS

U.S. Election Day (First Tuesday After the First Monday in November)

//All versions of HotDocs
DATE OF( 1, 11, Year )
RESULT + ( 2 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 11
  RESULT + 7 DAYS
END IF
RESULT + 1 DAY
 
//HotDocs 6.2 and later
DATE OF( 1, 11, Year )
WHILE DAY OF WEEK ( RESULT ) != 2
  RESULT + 1 DAY
END WHILE
RESULT + 1 DAY

Thanksgiving Day (Fourth Thursday in November)

//All versions of HotDocs
DATE OF( 1, 11, Year )
RESULT + ( 5 - DAY OF WEEK( RESULT ) ) DAYS
IF MONTH OF( RESULT ) != 11
  RESULT + 7 DAYS
END IF
RESULT + 21 DAYS
 
//HotDocs 6.2 and later
DATE OF( 1, 11, Year )
WHILE DAY OF WEEK ( RESULT ) != 5
  RESULT + 1 DAY
END WHILE
RESULT + 21 DAYS