ID:               43056
 Comment by:       vorlon at debian dot org
 Reported By:      vorlon at debian dot org
 Status:           Feedback
 Bug Type:         Date/time related
 Operating System: *
 PHP Version:      5.2.4
 New Comment:

No, I'm thankfully free of maintaining PHP packages now, I have no
intention of chasing CVS tarballs to check whether you've fixed the
code.


Previous Comments:
------------------------------------------------------------------------

[2008-10-26 23:47:00] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2007-10-21 06:22:15] vorlon at debian dot org

Description:
------------
The calendar extension's unixtojd() function is described in the php
manual as simply:

   unixtojd — Convert Unix timestamp to Julian Day

No further explanation is given for how a Julian Day is defined in this
case.  However, if we use the definition given at
<http://www.decimaltime.hynes.net/dates.html#jdn> which appears to be
the normal astronomical meaning of a Julian Day, a Julian Day should be
measured from noon GMT (or UT).

The problem is that the unixtojd() function uses php_localtime_r() to
convert a given UNIX timestamp to a time_t struct - which means the base
Gregorian date used for the conversion is calculated in the local
timezone, not in GMT.  This function should use php_gmtime_r() instead.

This problem was detected when running the PHP testsuite with TZ=UTC
set - the ext/calendar/tests/unixtojd.phpt test expects a value that is
only returned in a timezone west of GMT!
(Separately, I see nowhere that the 12h offset is taken into account,
so in practice all unixtojd() results are currently calculated from
midnight in the local timezone.)

Reproduce code:
---------------
<?php
setenv('TZ=America/Los_Angeles');
echo unixtojd(1000000000). "\n";
?>


Expected result:
----------------
2452162

Actual result:
--------------
2452161


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43056&edit=1

Reply via email to