PEAR Package 'Date' (Date/Date_Calc.php)
| From: | charles woodcock | Date: | Wed, 31 Oct 2007 12:16:56 +0000 |
| Subject: | PEAR Package 'Date' (Date/Date_Calc.php) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-48345@lists.php.net to get a copy of this message | ||
I made these changes to Date/Date_Calc.php but did not write a log because I did not know how to at
the time - sorry
defaultCentury()
- changed to predict the century based on the current year, rather than hard-coding for 19xx or 20xx
dateToDays()
- I tested this function and it was fine for years > 0; below this it broke, so I have modified
the algorithm
daysToDate()
- minor change
dateToDaysJulian()
daysToDateJulian()
- added these two functions in order to allow conversions from Gregorian to Julian and vice versa
gregorianToISO()
- this worked for years > 1500. Below this the algorithm broke, so I rewrote it completely and
called it:
isoWeekDate()
- I gave it a new name, because for dates < 0, the return format would be
'-YYYY-WW-D', where YYYY is the ISO year, WW is the ISO week and D is the ISO day. I
thought that because the delimiter is the same as the minus sign that this format is bound to catch
someone out, and anyway, the ISO 8601 standard requires an extra letter 'W' before the
week no, so it is not strictly ISO 8601 compliant anyway. (ISO 8601 does not actually talk about
negative years, it goes down to year 0 and that's it as far as I know).
If anyone disagrees with me we can talk about this if you want.
dayOfWeek()
- The algorithm broke for years < 0, so I implemented a different one which does work.
isValidDate()
- algorithm was valid from years 1 to 32767 only, so I reimplemented this as well
isLeapYearJulian()
isLeapYearGregorian()
- created these two functions and then moved some of the code from isLeapYear(). This doesn't
change the behaviour of the function, but I thought these would be necessary if you want to
implement any kind of calendar -specific behaviour
Other functions: most forbid the year 0, and replace it with the current year, which I have changed
so as to allow this year (I would call this a bug anyway because ISO 8601 recognizes the year 0).
Charles
p.s. How do you subscribe to this list because I have yet to receive a confirmation e-mail. Can
someone just add me? (c01234@netcomuk.co.uk)
charles woodcock <charles_woodc@yahoo.co.uk> wrote: Date: Wed, 31 Oct 2007 01:21:42 +0000
(GMT)
From: charles woodcock <charles_woodc@yahoo.co.uk>
Subject: Re: PEAR Package 'Date'
To: Firman Wandayandi <firman@php.net>
Dear Firman,
I am going to commit these changes to Date/Date_Calc.php:
defaultCentury()
- changed to predict the century based on the current year, rather than hard-coding for 19xx or 20xx
dateToDays()
- I tested this function and it was fine for years > 0; below this it broke, so I have modified
the algorithm
daysToDate()
- minor change
dateToDaysJulian()
daysToDateJulian()
- added these two functions in order to allow conversions from Gregorian to Julian and vice versa
gregorianToISO()
- this worked for years > 1500. Below this the algorithm broke, so I rewrote it completely and
called it:
isoWeekDate()
- I gave it a new name, because for dates < 0, the return format would be
'-YYYY-WW-D', where YYYY is the ISO year, WW is the ISO week and D is the ISO day. I
thought that because the delimiter is the same as the minus sign that this format is bound to catch
someone out, and anyway, the ISO 8601 standard requires an extra letter 'W' before the
week no, so it is not strictly ISO 8601 compliant anyway. (ISO 8601 does not actually talk about
negative years, it goes down to year 0 and that's it as far as I know).
Anyway it returns an array but we can talk about this if you want.
dayOfWeek()
- The algorithm broke for years < 0, so I implemented a different one which does work.
isValidDate()
- is valid from years 1 to 32767 only, so I reimplemented this as well
isLeapYearJulian()
isLeapYearGregorian()
- created these two functions and then moved some of the code from isLeapYear(). This doesn't
change the behaviour of the function, but I thought these would be necessary if you want to
implement any kind of calendar -specific behaviour
Other functions: forbid the year 0, and replace it with the current year, which I have changed.
Charles
---------------------------------
For ideas on reducing your carbon footprint visit Yahoo! For Good this month.
---------------------------------
Yahoo! Answers - Get better answers from someone who knows. Tryit now.