Hi,
I have a problem with Pike 7.2 and localtime. It looks like it returns different values on two machines:
On one running FreeBSD (other poeple have the same results with Debian) from pike compiled from source:
$ date Tue May 6 11:41:00 CEST 2003 $ date -u Tue May 6 09:41:02 UTC 2003 $ pike Pike v7.2 release 340 running Hilfe v2.0 (Incremental Pike Frontend)
localtime(time());
Result: ([ /* 10 elements */ "hour":11, "isdst":1, "mday":6, "min":33, "mon":4, "sec":54, "timezone":-7200, "wday":2, "yday":125, "year":103 ])
On a Debian woody from the pike package:
$ date Tue May 6 11:41:04 CEST 2003 $ date -u Tue May 6 09:41:05 UTC 2003 $ pike Pike v7.2 release 340 running Hilfe v2.0 (Incremental Pike Frontend)
localtime(time());
Result: ([ /* 10 elements */ "hour":11, "isdst":1, "mday":6, "min":34, "mon":4, "sec":1, "timezone":-3600, "wday":2, "yday":125, "year":103 ])
The problem is in the timezone value (3600 and 7200).
Do you have any ideads ?
Thank you for your answers.
The problem here isn't really a Pike problem.
"timezone" comes from either the tm_gmtoff or the __tm_gmtoff part of the struct tm structure, or from the timezone external variable if such a thing exist.
On Tue, 6 May 2003, Mirar @ Pike developers forum wrote:
...so I'd say it's a (g)libc issue.
Try the Calendar module which should calculate the right thing,
| > Calendar.now()->utc_offset(); | (1) Result: -7200
Ok, thanks.
Finally I have one more question, does the result of Calendar.now()->utc_offset(); takes daylight saving time into account ?
Finally I have one more question, does the result of Calendar.now()->utc_offset(); takes daylight saving time into account ?
Oh yeah. :)
Example of a Calendar module usage: http://www.mirar.org/timezone.pike
(http://www.mirar.org/timezone.pike.txt for the source. But beware, it's not cleaned up for viewing at all.)
/ Mirar
Previous text:
2003-05-06 12:54: Subject: Re: localtime
On Tue, 6 May 2003, Mirar @ Pike developers forum wrote:
...so I'd say it's a (g)libc issue.
Try the Calendar module which should calculate the right thing,
| > Calendar.now()->utc_offset(); | (1) Result: -7200
Ok, thanks.
Finally I have one more question, does the result of Calendar.now()->utc_offset(); takes daylight saving time into account ?
-- David Gourdelier
/ Brevbäraren
pike-devel@lists.lysator.liu.se