note 88468 modified in function.gregoriantojd by danbrown

From: Date: Mon, 26 Jan 2009 17:16:30 +0000
Subject: note 88468 modified in function.gregoriantojd by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149787@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: <?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); } ?> --was-- 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); } http://php.net/manual/en/function.gregoriantojd.php

« previous php.notes (#149787) next »