Re: Problem with DateTime::Format::DateManip v0.01
On Thu, 4 Sep 2003, Dave Rolsky wrote: > 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: You have to call tzset() on some platforms when you change TZ at runtime. # this prints Tokyo time export TZ="Asia/Tokyo" perl -le 'print scalar localtime' # and this doesn't on Solaris but does on Gentoo perl -le '$ENV{TZ} = "Asia/Tokyo"; print scalar localtime' # and this always does perl -MPOSIX -le '$ENV{TZ} = "Asia/Tokyo"; POSIX::tzset; print scalar localtime' So there is a difference, on some platform(s), between inheriting the value of TZ from the environment and setting it at runtime. Using tzset() is the 'portable' thing to do. Didn't I answer an almost identical question from David a few months ago? -J --
Re: Problem with DateTime::Format::DateManip v0.01
On Thursday, September 4, 2003, at 09:37 PM, Dave Rolsky wrote: 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' Damn, okay, thanks. Can you do another test for me (since I don't have a platform that needs tzset)? Can you tell me how it affects use of local? Here's a test script: #!/usr/bin/perl -w use strict; use POSIX qw(tzset); print scalar localtime, $/; { local $ENV{TZ} = "Asia/Tokyo"; tzset; print scalar localtime, $/; } print scalar localtime, $/; The question is, what does the third print statement print? Do I need to call tzset again after the block? TIA, David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7e Jabber: [EMAIL PROTECTED] Kineticode. Setting knowledge in motion.[sm]
Re: Problem with DateTime::Format::DateManip v0.01
On Friday, September 5, 2003, at 12:50 AM, Joshua Hoblitt wrote: So there is a difference, on some platform(s), between inheriting the value of TZ from the environment and setting it at runtime. Using tzset() is the 'portable' thing to do. Okay, thanks. Didn't I answer an almost identical question from David a few months ago? Possibly. I had reported an issue with TZs not appearing to work on Debian, but if you said exactly the above, I missed it. Sorry. I'm glad to have the information now! Cheers, David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7e Jabber: [EMAIL PROTECTED] Kineticode. Setting knowledge in motion.[sm]
Re: Problem with DateTime::Format::DateManip v0.01
On Fri, 5 Sep 2003, David Wheeler wrote: > Can you do another test for me (since I don't have a platform that > needs tzset)? Can you tell me how it affects use of local? Here's a > test script: > > #!/usr/bin/perl -w > use strict; > use POSIX qw(tzset); > > print scalar localtime, $/; > { > local $ENV{TZ} = "Asia/Tokyo"; > tzset; > print scalar localtime, $/; > } > print scalar localtime, $/; > > The question is, what does the third print statement print? Do I need > to call tzset again after the block? Yep, you need to call it again. Whatever tzset does is something at a C library level, not a Perl level, so the localization doesn't do anything. -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: Problem with DateTime::Format::DateManip v0.01
On Friday, September 5, 2003, at 09:51 AM, Dave Rolsky wrote: Yep, you need to call it again. Whatever tzset does is something at a C library level, not a Perl level, so the localization doesn't do anything. Bah. Thanks for that. Does this work? #!/usr/bin/perl -w use strict; use POSIX qw(tzset); print scalar localtime, $/; { local $ENV{TZ} = "Asia/Tokyo"; tzset; print scalar localtime, $/; } tzset; print scalar localtime, $/; Regards, David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7e Jabber: [EMAIL PROTECTED] Kineticode. Setting knowledge in motion.[sm]
Re: Problem with DateTime::Format::DateManip v0.01
On Fri, 5 Sep 2003, David Wheeler wrote: > Bah. Thanks for that. Does this work? > > #!/usr/bin/perl -w > > use strict; > use POSIX qw(tzset); > print scalar localtime, $/; > { > local $ENV{TZ} = "Asia/Tokyo"; > tzset; > print scalar localtime, $/; > } > tzset; > print scalar localtime, $/; yup /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: Problem with DateTime::Format::DateManip v0.01
On Friday, September 5, 2003, at 11:21 AM, Dave Rolsky wrote: Bah. Thanks for that. Does this work? yup Oh, good, at least I don't have to stash the value away and reassign it. Thanks, David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://www.kineticode.com/ Yahoo!: dew7e Jabber: [EMAIL PROTECTED] Kineticode. Setting knowledge in motion.[sm]