#48963 [Opn->Bgs]: Unexpected results when converting from Gregorian Date to Julian Day and back
| From: | jani@php.net | Date: | Fri, 17 Jul 2009 17:35:46 +0000 |
| Subject: | #48963 [Opn->Bgs]: Unexpected results when converting from Gregorian Date to Julian Day and back | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139886@lists.php.net to get a copy of this message | ||
ID: 48963
Updated by: jani@php.net
Reported By: satovey at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Windows XP Sp3 Xamp Apache
PHP Version: 5.2.10
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
$ php -r '$i = 0026; var_dump($i);'
int(22)
Previous Comments:
------------------------------------------------------------------------
[2009-07-17 17:26:47] satovey at yahoo dot com
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 this bug report at http://bugs.php.net/?id=48963&edit=1