Prior to the Finance package being updated to include holidays there was no easy way to have Maple generate when holidays occurred.  Hence for newer Maple users there would be no need for such a thing but I had an interest to create one for earlier versions.  The idea is quite simple enough and this is one solution I came up with.

I ran into trouble mathematically calculating easter (the first Sunday after the full moon after March 21st) I jumped to wikipedia for help and used the anonymous Gregorian algorithm which was originally published in Nature in 1876 since reprinted many times.

The holidays are specific to where Maplesoft resides ... Ontario, Canada.

This procedure generates holidays for the current year on your computer.  Just change your clock year to see other dates. 

As an excercise, change the procedure to include a user chosen year.  It may not be as simple as you think ..

 

Here is the proc



``

restart; gc()

``

``

holiday2 := proc () local a, b, c, d, e, f, g, h, i, k, L, m, month, day, Y; global dm, NewYears, FamilyDay, GoodFriday, EasterMonday, VictoriaDay, CanadaDay, CivicHoliday, LabourDay, Thanksgiving, Christmas, BoxingDay; dm := 86400; NewYears := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm); FamilyDay := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-2-1"))[yearDay]+dm*(`mod`(-StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-2-1"))[weekDay]+2, 7))+14*dm); VictoriaDay := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-5-25"))[yearDay]-dm*(`mod`(StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-5-25"))[weekDay]-3, 7)+1)); CanadaDay := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-7-1"))[yearDay]); CivicHoliday := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-8-1"))[yearDay]+dm*(`mod`(-StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-8-1"))[weekDay]+2, 7))); LabourDay := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-9-1"))[yearDay]+dm*(`mod`(-StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-9-1"))[weekDay]+2, 7))); Thanksgiving := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-10-1"))[yearDay]+dm*(`mod`(-StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-10-1"))[weekDay]+2, 7))+7*dm); Christmas := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-12-25"))[yearDay]); BoxingDay := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-12-26"))[yearDay]); Y := parse(StringTools:-FormatTime("%Y")); a := `mod`(Y, 19); b := floor((1/100)*Y); c := `mod`(Y, 100); d := floor((1/4)*b); e := `mod`(b, 4); f := floor((1/25)*b+8/25); g := floor((1/3)*b-(1/3)*f+1/3); h := `mod`(19*a+b-d-g+15, 30); i := floor((1/4)*c); k := `mod`(c, 4); L := `mod`(32+2*e+2*i-h-k, 7); m := floor((1/451)*a+(1/41)*h+(2/41)*L); month := floor((1/31)*h+(1/31)*L-(7/31)*m+114/31); day := `mod`(h+L-7*m+114, 31)+1; GoodFriday := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-", month, "-", day))[yearDay]-2*dm); EasterMonday := StringTools:-FormatTime("%a %b %e %Y", -dm*parse(StringTools:-FormatTime(%j))+dm*StringTools:-ParseTime("%Y-%m-%d", cat(StringTools:-FormatTime("%Y"), "-", month, "-", day))[yearDay]+dm); print("New Years", NewYears); print("Family Day", FamilyDay); print("Good Friday", GoodFriday); print("Easter Monday", EasterMonday); print("Victoria Day", VictoriaDay); print("Canada Day", CanadaDay); print("Civic Holiday", CivicHoliday); print("Labour Day", LabourDay); print("Thanksgiving", Thanksgiving); print("Christmas", Christmas); print("Boxing Day", BoxingDay) end proc:

holiday2()
                       "New Years", "Tue Jan  1 2013"
                       "Family Day", "Mon Feb 18 2013"
                      "Good Friday", "Fri Mar 29 2013"
                     "Easter Monday", "Mon Apr  1 2013"
                      "Victoria Day", "Mon May 20 2013"
                       "Canada Day", "Mon Jul  1 2013"
                     "Civic Holiday", "Mon Aug  5 2013"
                       "Labour Day", "Mon Sep  2 2013"
                      "Thanksgiving", "Mon Oct 14 2013"
                       "Christmas", "Wed Dec 25 2013"
                       "Boxing Day", "Thu Dec 26 2013"
BoxingDay

"Boxing Day", "Thu Dec 26 2013"

(1)

Thanksgiving

"Mon Oct 14 2013"

(2)

Christmas

"Wed Dec 25 2013"

(3)

FamilyDay

"Mon Feb 18 2013"

(4)

``



Download holidays3.mw


Please Wait...