Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.21.8

Bug #12807 Incorrect holiday computation
Submitted: 2008-01-02 12:57 UTC
From: webclaus Assigned: kguest
Status: Closed Package: Date_Holidays (version 0.17.1)
PHP Version: 5.2.4 OS: FreeBSD
Roadmaps: (Not assigned)    
Subscription  


 [2008-01-02 12:57 UTC] webclaus (Claus Rasmussen)
Description: ------------ It seems the package has a problem with X-mas dates in the Danish driver? I seem to recall having tested this, but the simple test script below doesn't really leave many other sources of errors than the Date_Holidays package? I tried using drivers for different countries as well, with the same result. Test script: --------------- include_once('Date/Holidays.php'); $holiDayObj =& Date_Holidays::factory('Denmark'); $time = mktime(1, 1, 1, 12, 25, 2007); echo 'Is ' . date('Ymd', $time) . ' a holiday?: ' . ($holiDayObj->isHoliday($time) ? 'YES' : 'NO') . "\n"; Expected result: ---------------- Is 20071225 a holiday?: YES Actual result: -------------- Is 20071225 a holiday?: NO

Comments

 [2008-01-02 13:21 UTC] wiesemann (Mark Wiesemann)
This seems to be a general problem with years different from the current year. In the Denmark driver (and others) the holidays are only added for the current year. // working examples: $time = mktime(1, 1, 1, 1, 1, 2008); $time = mktime(1, 1, 1, 12, 25, 2008); // not working examples: $time = mktime(1, 1, 1, 1, 1, 2007); $time = mktime(1, 1, 1, 1, 1, 2009); $time = mktime(1, 1, 1, 12, 25, 2007); $time = mktime(1, 1, 1, 12, 25, 2009);
 [2008-01-03 09:56 UTC] kguest (Ken Guest)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I've fixed this in the isHolidays method. The fix is: determine if the year of supplied date differs from the set year of the Date_Holidays object, if so use the setYear method to rebuild the array of holidays.