From: satovey at yahoo dot com
Operating system: Windows XP Sp3 Xamp Apache
PHP version: 5.2.10
PHP Bug Type: *Calendar problems
Bug description: Unexpected results when converting from Gregorian Date to
Julian Day and back
Description:
------------
When converting Gregorian date to Julian day and then back to the
Gregorian date, unexpected results can occur if the year being two digits
such as (26) is entered as a four digit (0026).
This produces a four year difference of 1461 days.
The quick solution to this is to enter four digit years such as 0026 as a
literal '0026'.
Reproduce code:
---------------
$month=3; $day=18; $year=26;
$gregToJd=gregoriantojd($month,$day,$year);
$gregDateFromJd=JdToGregorian($gregToJd);
echo "month: $month, day: $day, year: $year <br>";
echo "JulianDay from gregorian date: $gregToJd <br>";
echo "GregorianDate from julian day: $gregDateFromJd <br>";
$month=3; $day=18; $year=0026;
$gregToJd=gregoriantojd($month,$day,$year);
$gregDateFromJd=JdToGregorian($gregToJd);
echo "month: $month, day: $day, year: $year <br>";
echo "JulianDay from gregorian date: $gregToJd <br>";
echo "GregorianDate from julian day: $gregDateFromJd <br>";
$month=3; $day=18; $year='0026';
$gregToJd=gregoriantojd($month,$day,$year);
$gregDateFromJd=JdToGregorian($gregToJd);
echo "month: $month, day: $day, year: $year <br>";
echo "JulianDay from gregorian date: $gregToJd <br>";
echo "GregorianDate from julian day: $gregDateFromJd <br>";
Expected result:
----------------
One would expect the following output from the code:
month: 3, day: 18, year: 26
JulianDay from gregorian date: 1730633
GregorianDate from julian day: 3/18/26
month: 3, day: 18, year: 22
JulianDay from gregorian date: 1730633
GregorianDate from julian day: 3/18/26
month: 3, day: 18, year: 0026
JulianDay from gregorian date: 1730633
GregorianDate from julian day: 3/18/26
Actual result:
--------------
The actual output of the code is as follows:
month: 3, day: 18, year: 26
JulianDay from gregorian date: 1730633
GregorianDate from julian day: 3/18/26
month: 3, day: 18, year: 22
JulianDay from gregorian date: 1729172
GregorianDate from julian day: 3/18/22
month: 3, day: 18, year: 0026
JulianDay from gregorian date: 1730633
GregorianDate from julian day: 3/18/26
--
Edit bug report at http://bugs.php.net/?id=48963&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48963&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48963&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48963&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48963&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48963&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48963&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48963&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48963&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48963&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48963&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48963&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48963&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48963&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48963&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48963&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48963&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48963&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48963&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48963&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48963&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48963&r=mysqlcfg