note 88468 added to function.gregoriantojd
| From: | swiles at ddbc dot edu dot tw | Date: | Mon, 26 Jan 2009 05:32:24 +0000 |
| Subject: | note 88468 added to function.gregoriantojd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149766@lists.php.net to get a copy of this message | ||
The php gregoriantojd() and jdtogregorian() functions, in addition to the limitations noted by
httpwebwitch, does not take account of the 'Astronomical' system of reckoning - i.e. using
a year zero, instead of going directly from 1BCE to 1CE, as with the Christian Anno Domini system.
These functions can be used to wrap the php built-ins to return ISO 8601 compliant dates:
function ISO8601toJD($ceDate) {
list($day, $month, $year) = array_map('strrev',explode('-', strrev($ceDate),
3));
if ($year <= 0) $year--;
return gregoriantojd($month, $day, $year);
}
function JDtoISO8601($JD) {
if ($JD <= 1721425) $JD += 365;
list($month, $day, $year) = explode('/', jdtogregorian($JD));
return sprintf('%+05d-%02d-%02d', $year, $month, $day);
}
----
Server IP: 140.113.54.119
Probable Submitter: 125.232.128.152
----
Manual Page -- http://www.php.net/manual/en/function.gregoriantojd.php
Edit -- https://master.php.net/note/edit/88468
Del: integrated -- https://master.php.net/note/delete/88468/integrated
Del: useless -- https://master.php.net/note/delete/88468/useless
Del: bad code -- https://master.php.net/note/delete/88468/bad+code
Del: spam -- https://master.php.net/note/delete/88468/spam
Del: non-english -- https://master.php.net/note/delete/88468/non-english
Del: in docs -- https://master.php.net/note/delete/88468/in+docs
Del: other reasons-- https://master.php.net/note/delete/88468
Reject -- https://master.php.net/note/reject/88468
Search -- https://master.php.net/manage/user-notes.php