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

I also find it very frustrating, you would expect that you make  
gmmktime(0,0,0,2009,30,10) or somthing like this, then convert it to JD
and back to unix time and get the same not local time :/

Is that a bug that is going to be fixed or maybe documentation could be
updated so that people would understand what will happen?

Thanks a million

Art


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

[2008-11-03 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2008-10-27 03:43:49] vorlon at debian dot org

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.

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

[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