Recently I had to figure out a way to disable an automated process that would
run on a daily basis. Since the functionality of the Windows Task Scheulder
doesn’t easily support something like this I tried to think of a “set it and
forget it” solution.
For my purposes I had to disable my program from running based on the Federal
Reserve holiday list.
At the beginning of your program you are able to pass the current year to
the hashset, and it will return a list of the holidays you’ve specified.
Depending on the holiday you would like to add to the hashset I’ve included a
few ways you can easily find the date for each year.
AdjustForWeekendHoliday() - Will push the observed holiday date to Monday if
the holidays actual date is on a Sunday, and will move the observed holiday
to Friday if the actual date falls on a Saturday.
FindDay() - Is able to find a holiday if it occurs on a certain 2nd or 3rd
Monday of a Month.
Making use of both of these functions it’s quick and easy to add a day to the
hashset.
I’ll most likley use this in future projects that are required to not run on
certain days, and I hope others find this snippet useful as well.