[Rt-devel] RT 3.6.4rc2

Nicholas Clark nick at ccl4.org
Fri Jun 15 09:38:30 EDT 2007


> > -----Original Message-----
> > From: rt-devel-bounces at lists.bestpractical.com [mailto:rt-devel-
> > bounces at lists.bestpractical.com] On Behalf Of Jesse Vincent
> > Sent: Friday, June 15, 2007 7:53 AM

> > Fascinating.
> > 
> > TZ=GMT perl -e' print localtime()."\n"; $ENV{TZ} = "US/Eastern";
> > print localtime()."\n";'
> > 
> > Mac OS X:
> > 
> > Fri Jun 15 12:50:55 2007
> > Fri Jun 15 08:50:55 2007
> > 
> > 
> > Linux:
> > 
> > Fri Jun 15 12:51:51 2007
> > Fri Jun 15 12:51:51 2007
> > 
> > Both 5.8.8.
> > 
> > I wonder what bit of cleverness I'm missing.

On Fri, Jun 15, 2007 at 07:59:56AM -0500, Kelly F. Hickel wrote:
> Hmm, the obvious combinations work for me on centos 5.5.....
> 
> [root at starbug2 ~]# TZ=GMT perl -e' print localtime()."\n";'
> Fri Jun 15 12:58:10 2007
> [root at starbug2 ~]# TZ="US/Eastern" perl -e' print localtime()."\n";'
> Fri Jun 15 08:58:21 2007
> [root at starbug2 ~]# perl  -e' $ENV{TZ} = "GMT"; print localtime()."\n";'
> Fri Jun 15 12:59:08 2007
> [root at starbug2 ~]# perl  -e' $ENV{TZ} = "US/Eastern"; print
> localtime()."\n";'
> Fri Jun 15 08:59:15 2007

There appear to be two things interacting here (at least in Jesse's example)

On a FreeBSD machine that's in GMT I see:

$ TZ=US/Mountain perl -we' print localtime()."\n"; $ENV{TZ} = "US/Eastern"; print localtime()."\n";'
Fri Jun 15 13:31:51 2007
Fri Jun 15 13:31:51 2007
$ TZ=US/Eastern perl -we' print localtime()."\n"; $ENV{TZ} = "US/Mountain"; print localtime()."\n";'
Fri Jun 15 13:31:54 2007
Fri Jun 15 13:31:54 2007


so TZ is getting ignored.

Whereas an Ubuntu machine recognises the TZ strings:

$ TZ=US/Eastern perl -we' print localtime()."\n"; $ENV{TZ} = "US/Mountain"; print localtime()."\n";'
Fri Jun 15 09:32:56 2007
Fri Jun 15 09:32:56 2007
$ TZ=US/Mountain perl -we' print localtime()."\n"; $ENV{TZ} = "US/Eastern"; print localtime()."\n";'
Fri Jun 15 07:33:00 2007
Fri Jun 15 07:33:00 2007

then both print out that timezone at initialisation time, and the subsequent
change is ignored.

So OS X must be doing something "special" and resetting the timezone for every
call to localtime. Note that GMT isn't a great one to test with, as the
default for timezones you don't understand is 0, which is GMT.

$ TZ=Europe/London perl -we'print gmtime() . "\n" . localtime()."\n";'
Fri Jun 15 13:36:45 2007
Fri Jun 15 14:36:45 2007
$ TZ=US/Dubya perl -we'print gmtime() . "\n" . localtime()."\n";'
Fri Jun 15 13:37:05 2007
Fri Jun 15 13:37:05 2007


And no, I don't know more than this.

Nicholas Clark


More information about the Rt-devel mailing list