On Thu, 13 Feb 2003, Dave Rolsky wrote:

> Actually, I think it's correct.  The UNIX epoch is seconds since January
> 1, 1970 00:00:00 GMT.  So the GMT assumption is indeed correct.
>

But you are using Time::Local::timegm() to do the conversion.  timegm() is
the inverse of gmtime() which returns the year, month, day, hour, etc at
UTC.

You can see the difference at work (assuming you aren't in GMT) in:

($y, $m, $d, $h, $min) = (localtime)[5,4,3,2,1];
printf("%04d/%02d/%02d %02d:%02d\n", $y+1900, $m+1, $d, $h, $min);

($y, $m, $d, $h, $min) = (gmtime)[5,4,3,2,1];
printf("%04d/%02d/%02d %02d:%02d\n", $y+1900, $m+1, $d, $h, $min);


Therefore, before we can call timegm(), we need to cast DateTime's
internal year, month, day, hour, minute, second to GMT. (as it is my
understanding from looking at and playing with the code that DateTime
stores those values in local time)

Often in these situations you would use timelocal() but timelocal()
assumes the values you are passing are in the systems localtime and
doesn't provide an API to override that assumption.


Kellan

-- 
"the truth is always revolutionary" [antonio gramsci]

[EMAIL PROTECTED]

Reply via email to