php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25288 Wrong JulianDayCount
Submitted: 2003-08-28 06:25 UTC Modified: 2003-09-08 06:16 UTC
From: josep dot gorro at trendcomms dot es Assigned:
Status: Not a bug Package: Calendar related
PHP Version: 4.3.1 OS: WinNT
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: josep dot gorro at trendcomms dot es
New email:
PHP Version: OS:

 

 [2003-08-28 06:25 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-08 06:16 UTC] zak@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 08:01:29 2024 UTC