#27533 [Opn->Csd]: gmmktime can return wrong value on the night that DST comes into affect
| From: | rasmus@php.net | Date: | Fri, 12 Mar 2004 17:23:32 +0000 |
| Subject: | #27533 [Opn->Csd]: gmmktime can return wrong value on the night that DST comes into affect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56362@lists.php.net to get a copy of this message | ||
ID: 27533
Updated by: rasmus@php.net
Reported By: scottmacvicar at ntlworld dot com
-Status: Open
+Status: Closed
Bug Type: Date/time related
Operating System: *
PHP Version: 4CVS, 5CVS (2004-03-11)
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-03-12 12:10:16] rasmus@php.net
On my Linux box with TZ set to GMT I get:
1080259200 - 26
1080345600 - 27
1080432000 - 28
1080518400 - 29
which appears to me to be correct. But if this patch works around the
bug on Windows then I don't see any problem with it. I don't see how
it could negatively impact other platforms.
------------------------------------------------------------------------
[2004-03-09 09:44:15] webmaster at panyopanyo dot com
I too can confirm this occurs on my system which uses the clock
settings described here
------------------------------------------------------------------------
[2004-03-09 09:41:52] webmaster at ragnarokonline dot de
wfm with my local timezone (Germany, GMT+1) but I could reproduce it,
after I've changed the timzone to GMT+0 (Dublin, Edinburgh, Lissabon,
London)
Autodetect DST-Settings was always active.
------------------------------------------------------------------------
[2004-03-08 21:27:34] scottmacvicar at ntlworld dot com
Description:
------------
This bug seems to have different affect on Windows and Linux.
Windows
------
System has to be running GMT and Automatically adjust clock for
daylight savings time checked.
You'll notice that the 27th appears twice. The second occurence of the
27th is Sat Mar 27 23:00:00 2004.
------
Redhat 9.0
------
The timestamp for linux on the 28th is Sun Mar 28 02:00:00 2004
/etc/sysconfig/clock
ZONE="Europe/London"
UTC=true
ARC=false
------
So Windows lost an hour and linux gained 2 hours.
Patch
--- datetime.c 2004-03-09 02:19:32.000000000 +0000
+++ datetime.c.patched 2004-03-09 02:20:48.000000000 +0000
@@ -192,8 +192,8 @@
/* fall-through */
case 1: /* hour */
val = (*arguments[0])->value.lval;
- if (val < 1) {
- chgsecs += (1-val) * 60*60; val = 1;
+ if (val < 2) {
+ chgsecs += (2-val) * 60*60; val = 2;
}
ta->tm_hour = val;
/* fall-through */
Changing the time to
02:01:01 seems to correct this issue and the windows machine stops
eating an hour and not setting tm_idst to 1 and i have no idea whats
going on with the linux machine.
Reproduce code:
---------------
<?php
for ($i = 26; $i <= 29; $i++)
{
$datestamp = gmmktime(0, 0, 0, 3, $i, 2004);
$day = gmdate('j', $datestamp);
echo "$datestamp - $day\n\n";
}
?>
Expected result:
----------------
1080259200 - 26
1080345600 - 27
1080432000 - 28
1080518400 - 29
Actual result:
--------------
Windows
---
1080259200 - 26
1080345600 - 27
1080428400 - 27
1080518400 - 29
Linux
---
1080259200 - 26
1080345600 - 27
1080439200 - 28
1080518400 - 29
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27533&edit=1