#25288 [Opn->Bgs]: Wrong JulianDayCount
| From: | zak@php.net | Date: | Mon, 08 Sep 2003 10:16:41 +0000 |
| Subject: | #25288 [Opn->Bgs]: Wrong JulianDayCount | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47237@lists.php.net to get a copy of this message | ||
ID: 25288
Updated by: zak@php.net
Reported By: josep dot gorro at trendcomms dot es
-Status: Open
+Status: Bogus
Bug Type: Calendar related
Operating System: WinNT
PHP Version: 4.3.1
New Comment:
The fault here lies with Excel.
Julian Day Counts start at noon, rather than midnight.
Combine this with the timezone of your computer and you
likely have your first day of error.
Excel also believes that February 29, 1900 is a valid
day. This accounts for day two of your error.
Previous Comments:
------------------------------------------------------------------------
[2003-08-28 06:25:20] josep dot gorro at trendcomms dot es
Description:
------------
I'm generating a function to calculate a date in Julian day count to be
used in excel spreadsheet. Always I obtain a 2 days difference. Is this
a bug?
Reproduce code:
---------------
<?php
// This is the date that I would to convert
$jd1 = GregorianToJD (8,28,2003);
print "$jd1\n";
$gregorian1 = JDToGregorian ($jd1);
print "$gregorian1\n";
// This is the initial excel's date counter
$jd2 = GregorianToJD (1,1,1900);
print "$jd2\n";
$gregorian2 = JDToGregorian ($jd2);
print "$gregorian2\n";
// This is the REAL (not bogus) day counter
$total=$jd1 - $jd2 + 2;
print "Excel value: ".$total;
?>
Expected result:
----------------
Without the correction ($total=$jd1 - $jd2;) the result is:
2452880 8/28/2003
2415021 1/1/1900
Real counter: 37859
Whit the correction ($total=$jd1 - $jd2 + 2;) the result is:
2452880 8/28/2003
2415021 1/1/1900
Real counter: 37861
First one isn't correct, second one is fine.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25288&edit=1