Calculating floating holidays
If you were looking for the calendar with holidays, you can find it [here]
In this FAQ, we will go through the calculations of floating holidays, with examples.
Most programming languages have no native support for calculating floating holidays, and it is difficult to find information on how to calculate those holidays.
The examples are written in Java, but are easily translated into other similar languages.
Feel free to use the examples, as long as www.dayweekyear.com is mentioned as the source.
If you wish to use the examples server side, and not written in a blog, then it is not necessary to mention the source. If you have any questions about the examples, feel free to ask me at [ the contact page ]
In this FAQ, we will go through the calculations of floating holidays, with examples.
Most programming languages have no native support for calculating floating holidays, and it is difficult to find information on how to calculate those holidays.
The examples are written in Java, but are easily translated into other similar languages.
Feel free to use the examples, as long as www.dayweekyear.com is mentioned as the source.
If you wish to use the examples server side, and not written in a blog, then it is not necessary to mention the source. If you have any questions about the examples, feel free to ask me at [ the contact page ]
Easter calculation.
Used for calculating: Easter, Ascension Day, Whit Sunday, Whit Monday, General prayer day (Danish holiday), Shrovetide, Palm Sunday and more.
Easter Sunday is the first Sunday after the 14th day of the lunar month (the nominal full moon) that falls on or after the 21 of March.
The algorithm used in the calendar on www.dayweekyear.com, is based on
Jean Meeus's algorithm from "Astronomical Algorithms" (1991) (Which quotes Spencer Jones and his book General Astronomy (1922)
and "Journal of the British Astronomical Association (1977)").
[ Read more about calculating easter on wikipedia ]
The Easter calculation used on på www.dayweekyear.com
[ Read more about calculating easter on wikipedia ]
The Easter calculation used on på www.dayweekyear.com
Calculating holidays depended on easter.
Used for calculating: Easter, Ascension Day, Whit Sunday, Whit Monday, General Prayer Day (Danish holiday), Shrovetide, Palm Sunday and more.
During a year, a lot of holidays are depended on easter. The common thing for all of them is, they are a
number of days before or after Easter. When you have the Easter calculation, it is easy to calculate the rest.
However holidays before Easter, can, in leap years, be one day before.
List of holidays depended on Easter:
Calculating holidays depended on Easter, used on www.dayweekyear.com
The method requires the Easter calculation above.
However holidays before Easter, can, in leap years, be one day before.
List of holidays depended on Easter:
| Holiday | Days after Easter (before Easter has negative values) |
| Palm sunday | -7 |
| Shovretide | -49 (-50 at leap years, sometimes) |
| Maundy Thursday | -3 |
| Good Friday | -2 |
| Easter monday | 1 |
| General Prayer Day | 26 |
| Ascension Day | 39 |
| Whit Monday | 49 |
| Whit Tuesday | 50 |
Calculating holidays depended on Easter, used on www.dayweekyear.com
The method requires the Easter calculation above.
Calculating specific weekday, which are the 1.,2.,3.,... weekday (e.g. Sunday), before a date.
Used for calculations of: 1., 2., 3., 4. Sunday before Christmas and Memorial Day (United States).
The method for calculating these holidays:
Set the starting date, to the date we are going backwards from. Make a counter, which starts at the number of times the weekday occurs before the actual date.
Run the following loop: Is the date the weekday we are looking for?
If yes, subtract 1 from the counter.
If the counter is 1, return the date, otherwise subtract 1 day and repeat the loop. The loop finds the date, and the starting date (if happening on the weekday) is included in the count. If the date should not be included, start with subtracting one day from the date.
Calculation of holidays, which are the 1.,2.,3.,... specific weekday before a date, as used on www.dayweekyear.com
Set the starting date, to the date we are going backwards from. Make a counter, which starts at the number of times the weekday occurs before the actual date.
Run the following loop: Is the date the weekday we are looking for?
If yes, subtract 1 from the counter.
If the counter is 1, return the date, otherwise subtract 1 day and repeat the loop. The loop finds the date, and the starting date (if happening on the weekday) is included in the count. If the date should not be included, start with subtracting one day from the date.
Calculation of holidays, which are the 1.,2.,3.,... specific weekday before a date, as used on www.dayweekyear.com
Calculation of holiday, which are the 1.,2.,3., specific weekday within a month.
Used for: Mothers Day, All Saints Day (Sweden), Alot of holidays in Canada and USA (among those: Labors day and Thanksgiving)
This calculation is done the same way as the calculation of holidays, which are the 1.,2.,3. specific weekday before a date
An example of this holiday is Mothers Day, which occurs the second Sunday in May.
Calculation of holidays, which are the 1.,2.,3., specific weekday within a month, used on www.dayweekyear.com
An example of this holiday is Mothers Day, which occurs the second Sunday in May.
Calculation of holidays, which are the 1.,2.,3., specific weekday within a month, used on www.dayweekyear.com
Calculation of holidays, which are a certain weekday, between two dates.
Used for calculation of: Midsummer's Day (Sweden and Finland), All Saints Day (Sweden), The Queens Birthday (Australia), Early May Bank Holiday (United Kingdom), Spring Bank Holiday (Great Britain) and Summer Holiday (United Kingdom).
This is a simple calculation, start on the first date.
Run in a loop the following way:
Are we on the specific weekday?
If not, add one day (until we pass the end date)
Calculation of holidays, which are a specific weekday, between two dates, as used on www.dayweekyear.com
Run in a loop the following way:
Are we on the specific weekday?
If not, add one day (until we pass the end date)
Calculation of holidays, which are a specific weekday, between two dates, as used on www.dayweekyear.com
The extra holiday rule.
Used for calculation of: Extra holidays at Christmas and New Year in United Kingdom.
In United Kingdom, there is an ekstra rule for holidays. If e.g. Christmas is on a Saturday, then the next Monday is a bank holiday.
This rule is a bit complicated to calculate, but it can be done, the following way.
Create a map with every holiday during the year, except the one you wish to test.
E.g. without Christmas Day if you want to test for extra bankholiday on Christmas Day: 1. Create a map with all holidays, without Sundays and Christmas Day.
2. Test if you get an extra holiday.
The method of testing and finding the extra holiday:
Is it a Saturday, Sunday or another holiday?
If no, return nothing, since we don't have an extra holiday.
If yes, test the next day, if it is a Saturday, Sunday or another holiday, continue until it is not, and return the day.
Calculation of extra bank holidays in United Kingdom, at Christmas and New Year, used on www.dayweekyear.com
This rule is a bit complicated to calculate, but it can be done, the following way.
Create a map with every holiday during the year, except the one you wish to test.
E.g. without Christmas Day if you want to test for extra bankholiday on Christmas Day: 1. Create a map with all holidays, without Sundays and Christmas Day.
2. Test if you get an extra holiday.
The method of testing and finding the extra holiday:
Is it a Saturday, Sunday or another holiday?
If no, return nothing, since we don't have an extra holiday.
If yes, test the next day, if it is a Saturday, Sunday or another holiday, continue until it is not, and return the day.
Calculation of extra bank holidays in United Kingdom, at Christmas and New Year, used on www.dayweekyear.com


