php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37358 date_sunrise() date_sunset() handle main zone offset but not count summer time
Submitted: 2006-05-08 04:35 UTC Modified: 2008-11-10 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: ache at nagual dot pp dot ru Assigned: derick (profile)
Status: No Feedback Package: Date/time related
PHP Version: 5.1.4 OS: FreeBSD
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: ache at nagual dot pp dot ru
New email:
PHP Version: OS:

 

 [2006-05-08 04:35 UTC] ache at nagual dot pp dot ru
Description:
------------
In php_date.c I see some (unsuccessful) effort to calculate proper offset, I mean line

gmt_offset = timelib_get_current_offset(t) / 3600;

but it gets only _main_ zone offset, without current summer time added. I.e. for Europe/Moscow it _always_ gets 3, but in the summer it must be 4.

This code can't work in any case, because it consider 'time' argument only few lines later: 

timelib_unixtime2local(t, time);

but at the moment timelib_get_current_offset(t) called, 'time' arg simple unused, so you can't get summer offset this way, only main one.

Please fix the code to count summer time too,

Reproduce code:
---------------
I have following lines in my php.ini:
date.default_latitude=55.75
date.default_longitude=37.61
date.timezone=Europe/Moscow

and call this test script when summer time (+0400) is active:
<?php
echo date("r").', '.date_sunrise(time()).', '.date_sunset(time());
echo date("r").', '.date_sunrise(time(),SUNFUNCS_RET_STRING,55.75,37.61,90.583333,4).', '.date_sunset(time(),SUNFUNCS_RET_STRING,55.75,37.61,90.583333,4);
?>

Expected result:
----------------
Two echo calls must produce the same sunrise/sunset results when summer Moscow time (GMT+4, specified directly in the second echo call) is active.

Actual result:
--------------
Sunset/sunrise time of the first echo is one hour behind (GMT+3), when script called with summer time active. 
date() call itself reports +0400 properly.
Moreover, I consult astronomical tables, first sunrise/sunset is definitely one hour behind.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-08 07:13 UTC] derick@php.net
Interesting, as it works fine for me in Europe/Oslo. Will check it out.
 [2006-08-07 20:57 UTC] jmatos at math dot ist dot utl dot pt
Similar problem for Lisbon, Portugal, php 5.1.4, Linux Fedora Core 5.
Page exhibiting problem:
http://www.math.ist.utl.pt/responsaveis.phtml?cursos=ALL
(the hour is one hour off; system time is correct)

Page code contains
...
setlocale ('LC_TIME', 'pt_PT');
echo strftime ("%d de %B de %Y, %H:%M");
...
 [2008-11-02 12:35 UTC] jani@php.net
Please try using this CVS snapshot:

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

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


 [2008-11-10 01:00 UTC] 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC