Skip Menu |

This queue is for tickets about the Date-Manip CPAN distribution.

Report information
The Basics
Id: 102378
Status: resolved
Priority: 0/
Queue: Date-Manip

People
Owner: Nobody in particular
Requestors: jeff [...] endpoint.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Holiday config file for NZ fails to recognize all holidays
Date: Thu, 26 Feb 2015 11:51:12 -0500
To: bug-Date-Manip [...] rt.cpan.org
From: Jeff Boes <jeff [...] endpoint.com>
Perl version: 5.10.0 Module version: 5.54 Here is a configuration file we are working on for NZ: ----snip---- WorkWeekBeg = 1 WorkWeekEnd = 5 WorkDayBeg = 0:00 WorkDayEnd = 23:59 *Holiday # Other New Zealand holidays; see: # http://en.wikipedia.org/wiki/Public_holidays_in_New_Zealand 1*1:0:2:0:0:0*NWD = Day after New Year's Day (observed) 1*1:0:1:0:0:0*NWD = New Year's Day (observed) 1*2:0:6:0:0:0*NWD = Waitangi Day (observed) 1*0:0:0:0:0:0*EASTER,PD5 = Good Friday (Friday before Easter) 1*0:0:0:0:0:0*EASTER,ND1 = Easter Monday (Monday after Easter) 1*4:0:25:0:0:0*NWD = Anzac Day (observed) first Monday in June = Queen's Birthday fourth Monday in October = Labour Day (New Zealand) 1*12:0:24:0:0:0*FW1 = Christmas Day (observed) 1*12:0:25:0:0:0*FW1 = Boxing Day (observed) # United States UPS holidays # ** must be defined after country specific, so that New Year's/Christmas Day calc above is done correctly January 1 = New Year's Day last Monday in May = Memorial Day (U.S.) July 4 = Independence Day (U.S.) first Monday in September = Labour Day fourth Thursday in November = Thanksgiving Day (U.S.) December 25 = Christmas Day December 31 = New Year's Eve ----snip---- With this configuration loaded, the dates 2013-12-27 2014-12-29 2015-12-29 are all recognized as holidays, incorrectly. If you comment out the two lines here: #1*1:0:2:0:0:0*NWD = Day after New Year's Day (observed) #1*1:0:1:0:0:0*NWD = New Year's Day (observed) then the three dates are NOT recognized as holidays (correct), but then 2013-01-02, 2014-01-02, and 2015-01-02 are no longer holidays (expected but incorrect). -- Jeff Boes <>< jeff@endpoint.com 269-408-0811
There are three problems to address. First, you are using Date::Manip 5.54 which was released back in 2008. Date::Manip 5.xx is no longer developed or supported, so you should should upgrade to a 6.xx version if at all possible. Second, your definition of New Years and the day after are not correct. Using the most recent version of Date::Manip (6.49) and your config file, I test a bunch of dates to see if they are holidays, and get the following results: 2012-01-01 :: New Year's Day 2012-01-02 :: Day after New Year's Day (observed) 2012-01-03 :: New Year's Day (observed) Notice how 'New Year's Day (observed)' is AFTER 'Day after New Year's Day (observed)'. Your config file needs to define New Years (observed) before the day after New Years (observed). I'll leave it as an exercise to you to figure out why that is, but reading your config file, I knew that would happen and looked for a year that would demonstrate this problem. Third, you need to use the definitions: 1*12:0:25:0:0:0*NWD = Christmas 1*12:0:26:0:0:0*NWD = Boxing Using the FW1 flags (which may have been the documented recommendation in the 5.xx manuals) does not produce the results you want because FD1 automatically starts at a business day. Using: 1*12:0:24:0:0:0*FW1 = Christmas Day (observed) 1*12:0:25:0:0:0*FW1 = Boxing Day (observed) the first one defines 2012-12-25 as a holiday (Christmas Day observed) and then the second one looks at 2012-12-25 (the base date given) but since it is a holiday, one full business day later is 2012-12-27 at the start of the business day, and that's the result you get. This has been corrected in the newer documentation, and if you change the definitions, it should work, even in 5.xx.