Re: pear calendar

From: Date: Sun, 16 May 2004 22:39:09 +0000
Subject: Re: pear calendar
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12530@lists.php.net to get a copy of this message
On 16 May 2004 at 21:51, PHPDiscuss - PHP Newsgroups a wrote: > I've found out about how if you define CALENDAR_ENGINE to PearDate, you > can go before 1970 or after 2038 in dates. So I tried it and it works > beautifully; but I seem to have oen problem, which I think (not positive > but might) be related to doing this. > > I want to use the adjust method for when a date is invalid; and it makes > my coding a little easier when I go to a previous or next month. However I > have noticed that this isn't always accurate. for instance if I go from > january 2004 to December 2003 (with month 0 year 2004), the end day of > december 2003 is a few days before the beginning day of january. according > to the calendar jan 1 is on a Thursday, and then I use adjust with the > invalid date month 0 of 2004, it says that dec 31 is on Monday. If I just > enter month 12 of 2003 it works fine, though. I thought this might be > because, well, I don't think using the PearDate option uses timestamps, > does it? does adjust rely on these timestamps to fix the problem? I may be > way off course here, but it is a guess. Hmm, not sure I got you right in this respect. Could you post a short (!) demo-source with expected result, actual result and a short explanation in the source? > Second question is a curiosity. How far back or ahead can it go with use > PearDate in that definition? I have gone pretty far back and it has not > complained...though it does have a problem with leap years before year > 1000 :)!!!! not that that should be of any major worry... This results from Date/Calc.php in the Date-package. In the function isLeapYear() there is explicitly written: if ($year < 1000) { return false; } Another magic year-value is 1582: if ($year < 1582) { // pre Gregorio XIII - 1582 return ($year % 4 == 0); } else { // post Gregorio XIII - 1582 return ( (($year % 4 == 0) and ($year % 100 != 0)) or ($year % 400 == 0) ); } If I remember correctly this has historical reasons about when leapyear-corrections where introduced and how. So I suspect that also the values you get for the years <1000 are correct. Or did I interpret your question wrong? > but should it be able to go back to year 1 CE? It hasn't complained when I > tried, but, well, just curious. Why not? I mean, what's that special about year 1? :-)) From the source of Calendar in Engine/PearDate.php you'll see that it officially claims support down to year 0. Regards, Stefan

« previous php.pear.general (#12530) next »