note 88468 deleted from function.gregoriantojd by danbrown
| From: | danbrown@php.net | Date: | Mon, 26 Jan 2009 17:20:02 +0000 |
| Subject: | note 88468 deleted from function.gregoriantojd by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149789@lists.php.net to get a copy of this message | ||
Note Submitter: swiles at ddbc dot edu dot tw
----
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:
<?php
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);
}
?>