Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

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



Subject: Date_NextWorkDay behaviour change from 5.X to 6.X with holidays
Hello and thanks for Date::Manip, When attempting to upgrade from 5.56 to 6.22 I noticed a change in behaviour that I'm not sure is documented/expected. us_holidays.cnf contains: *HOLIDAYS 1*7:0:4:0:0:0*CWD = Independence Day (observed) use Date::Manip; Date_Init(q{GlobalCnf=us_holidays.cnf}); my $two_work_days_after_july_1_with_us_hol = Date_NextWorkDay ('20110701',2); 6.22 returns 20110705 5.56 returns 20110706 this is what I'd expect 2011 July 1 Fri 2 Sat 3 Sun 4 Mon holiday 5 Tue 6 Wed <- would expect 6th to be returned 7 Thur 8 Fri I did read the Changes5to6, and it seems related to: http://search.cpan.org/~sbeck/Date-Manip- 6.22/lib/Date/Manip/Changes5to6.pod#DATE_PARSING_AND_OPERATIONS Date_PrevWorkDay behavior Cheers, Peter (Stig) Edwards
There are three problems here. First, there was a bug in Date_Init. It wasn't loading the GlobalCnf file correctly (since that is deprectated, I'm afraid I didn't give it the same level of testing, and I missed a problem). I've fixed this and it'll be in the new release (6.23). The fix is pretty trivial. In Date::Manip::DM6 in the Date_Init function, change line 95 to be: $date->config(@args2,"oldconfigfiles",1); Of course, you'd be better off using the 'ConfigFile' option to load in your config files at this point which avoids the problem. The second problem is that your defintion SHOULD be: 1*7:0:4:0:0:0*DWD = Independence Day (observed) The CWD will never assign it to July 4. The CWD should only choose the closest working day before or after a date. The third problem is that you found a bug in the old 5.xx version since CWD shouldn't have worked then (but it did). Since that code is getting very limited support, I'll look into this when I have time. Anyway, the final answer is: o Change CWD to DWD in the definition o Use Date_Init('ConfigFile=us_holidays.cnf'); and things should work fine. Alternately, make the change to the DM6.pm file mentioned above, and change CWD to DWD in the definition and it'll work.
Thank you. I made the change to Date::Manip::DM6 and it fixes the behaviour. I'm performing the upgrade to 6.X on behalf of a user base that will benefit from your efforts to make sure that 6.xx is almost backwards compatible with 5.xx I suspect the user that *incorrectly* added: 1*7:0:4:0:0:0*CWD = Independence Day (observed) 1*12:0:25:0:0:0*CWD = Christmas (observed) May have been looking at: 1*11:0:11:0:0:0*CWD = Veteran's Day (observed) in some of the docs, should this also be changed to DWD? http://search.cpan.org/grep?cpanid=SBECK&release=Date-Manip- 6.22&string=Veteran&i=1&n=1&C=0 http://search.cpan.org/grep?cpanid=SBECK&release=Date-Manip- 5.56&string=Veteran&i=1&n=1&C=0 Thanks again.
Show quoted text
> I suspect the user that *incorrectly* added: > > 1*7:0:4:0:0:0*CWD = Independence Day (observed) > 1*12:0:25:0:0:0*CWD = Christmas (observed) > > May have been looking at: > > 1*11:0:11:0:0:0*CWD = Veteran's Day (observed) > > in some of the docs, should this also be changed to DWD?
Absolutely. It will be done in the next release. My apologies for having a bad example in the docs.