Bug #53148 [Asn->Opn]: date_sunrise and date_sunset show tomorrow's times for some timezones.
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 07:52:40 +0000 |
| Subject: | Bug #53148 [Asn->Opn]: date_sunrise and date_sunset show tomorrow's times for some timezones. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212172@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53148&edit=1
ID: 53148
Updated by: kalle@php.net
Reported by: sec at mboca dot com
Summary: date_sunrise and date_sunset show tomorrow's times
for some timezones.
-Status: Assigned
+Status: Open
Type: Bug
Package: Date/time related
Operating System: linux and windows
PHP Version: 5.2.14 and 5.3.3
-Assigned To: derick
+Assigned To:
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2013-10-28 22:14:00] phpnet at stanton dot co dot nz
PHP 5.3.15 Also has this issue though I don't believe it is related to the timezone being +12
or over
Keeping the timezone the same I changed the longitude value from 175 to 180 in 0.25 increments and
found the sunrise/set values jump to the next day at different longitudes according to the time of
the year.
Checking for the sunrise time on Oct 1st 2013 10:35 (NZ summer time) at longitude 177.25 gets
2013-10-01T06:45:18+13:00 but shift the longitude to 177.5 at the sunrise is reported as
2013-10-02T06:44:18+13:00
Checking for the sunrise time on Oct 31st 2013 10:35 (NZ standard time) at longitude 175.75 gets
2013-10-31T06:09:32+13:00 but shift the longitude to 176 at the sunrise is reported as
2013-11-01T06:08:32+13:00
------------------------------------------------------------------------
[2010-10-31 10:32:15] sec at mboca dot com
I figured out a workaround to this bug.
you have to add -1 day to subtract one day from sunrise and sunset times.
if ($offset >= 12 && strcmp(date_default_timezone_get(), "Pacific/Tarawa") !=
0) {
echo "+12 GMT workaround done<br>";
$sunrise = strtotime('-1 day', $sunrise);
$sunset = strtotime('-1 day', $sunset);
$csunrise = strtotime('-1 day', $csunrise);
$csunset = strtotime('-1 day', $csunset);
$nsunrise = strtotime('-1 day', $nsunrise);
$nsunset = strtotime('-1 day', $nsunset);
$asunrise = strtotime('-1 day', $asunrise);
$asunset = strtotime('-1 day', $asunset);
}
I need to test on time zones that are -12 in offsets
might have to do +1 day on that offset.
------------------------------------------------------------------------
[2010-10-28 06:33:38] sec at mboca dot com
It happens on php 5.3.3 too.
------------------------------------------------------------------------
[2010-10-28 06:32:07] sec at mboca dot com
This bug also happens on php 5.3.3 with same configure line in my post above.
------------------------------------------------------------------------
[2010-10-25 03:44:01] sec at mboca dot com
Description:
------------
when you try to get sunrise and sunset times from the area that have GMT +12 or over. the sunrise
and sunset times will be listed for next day.
The sunrise and sunset times should be listed for today.
http://weatherpixel.com/bug.php
the source code is at http://weatherpixel.com/bug.php?src=show
one of the examples that the Fiji Island times would only show for tomorrow and
my script would show it as night as always.
http://weatherpixel.com/sunrise_gmt.php?station=NFFN
Here is my configure line for linux:
./configure --enable-sockets --enable-calendar --with-curl=/usr/lib/ --with-gd
--with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --with-ttf --enable-gd-native-ttf
--with-gettext --with-freetype-dir=/usr/local/lib --without-sqlite --without-pdo-sqlite
--with-apxs2=/usr/local/apache2/bin/apxs
Test script:
---------------
here is php script that reproduce the date_sunrise
http://weatherpixel.com/bug.php?src=show
Expected result:
----------------
the times for +12 GMT and more than +12 GMT will always show tomorrow's sunrise and sunset
times.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53148&edit=1