On Thu, 4 Sep 2003, David Wheeler wrote:

> > It's probably that simple.  Simply setting the TZ env var probably
> > won't
> > do much.  An app has to call POSIX::tzset() for that take effect.
>
> I find that for most date and time handling I do, just setting $ENV{TZ}
> does the trick -- except perhaps on Debian. Are you saying that if I
> want the setting of TZ to portably affect, e.g., localtime, that I need
> to always POSIX::tzset() after I do it? Seems a waste to load all of
> POSIX.pm just for that...

I'm pretty sure you have to do that.  For example, if you simply set
$ENV{TZ} then localtime() doesn't change in this script:

 perl -le 'print scalar localtime; $ENV{TZ} = "Asia/Tokyo"; print scalar localtime'

But in this one it does

 perl -MPOSIX -le 'print scalar localtime; $ENV{TZ} = "Asia/Tokyo"; POSIX::tzset(); 
print scalar localtime'


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to