TZ cache on some Linux kernels

Discussion in 'Perl Misc' started by Jon, Oct 1, 2003.

  1. Jon

    Jon Guest

    While doing some time/date functions I had to change the timezone used
    (by changing the ENV{TZ}) twice in one script. However, it seems the
    kernel cached the last zone and failed to open or change to the new
    one. I confirmed this using strace, as you could see it only opened
    the one file. The code I used is as follows.

    $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';

    $time = time();

    ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
    localtime($time);
    print "$hour:$min\n";

    $ENV{TZ} = ':/usr/share/zoneinfo/Europe/Paris';

    ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
    localtime($time);
    print "$hour:$min\n";

    Is the code I used. The times should be out by an hour (Paris is one
    hour ahead of London), however for me they both show the same time,
    which is within the London (GMT+1) timezone. The results were
    different on another server.

    Linux 2.4.20 complied from source, Perl 5.8.0 (RedHat RPM) - failed.
    Linux 2.4.7 RedHat supplied, Perl 5.6.0 (RedHat RPM) - worked.

    I should really repeat the tests with the same version of Perl on both
    kernels, this time I will build Perl myself, I will try that later
    today, but I wonder if anyone else can confirm this issue or maybe
    point me in the direction of the problem.

    Jon.
    Jon, Oct 1, 2003
    #1
    1. Advertising

  2. On 1 Oct 2003 10:27:46 -0700, Jon <> wrote:
    > While doing some time/date functions I had to change the timezone used
    > (by changing the ENV{TZ}) twice in one script. However, it seems the
    > kernel cached the last zone and failed to open or change to the new
    > one. I confirmed this using strace, as you could see it only opened
    > the one file. The code I used is as follows.
    >
    > $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';
    >
    > $time = time();
    >
    > ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
    > localtime($time);
    > print "$hour:$min\n";
    >
    > $ENV{TZ} = ':/usr/share/zoneinfo/Europe/Paris';
    >
    > ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
    > localtime($time);
    > print "$hour:$min\n";
    >
    > Is the code I used. The times should be out by an hour (Paris is one
    > hour ahead of London), however for me they both show the same time,
    > which is within the London (GMT+1) timezone. The results were
    > different on another server.
    >
    > Linux 2.4.20 complied from source, Perl 5.8.0 (RedHat RPM) - failed.
    > Linux 2.4.7 RedHat supplied, Perl 5.6.0 (RedHat RPM) - worked.


    man tzslect (to see what to use for TZ). Try:

    $ENV{TZ} = 'Europe/London';
    $time = time();
    print scalar localtime($time)."\n";
    $ENV{TZ} = 'Europe/Paris';
    print scalar localtime($time)."\n";

    --
    David Efflandt - All spam ignored http://www.de-srv.com/
    http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
    http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
    David Efflandt, Oct 2, 2003
    #2
    1. Advertising

  3. [A complimentary Cc of this posting was sent to
    Jon
    <>], who wrote in article <>:
    > While doing some time/date functions I had to change the timezone used
    > (by changing the ENV{TZ}) twice in one script. However, it seems the
    > kernel cached the last zone and failed to open or change to the new
    > one. I confirmed this using strace, as you could see it only opened
    > the one file. The code I used is as follows.
    >
    > $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';


    Check whether tzset() is required on your system... It is a Perl bug
    that it does not call tzset() when/if required.

    In principle, tzset() is available in POSIX.

    Hope this helps,
    Ilya
    Ilya Zakharevich, Oct 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    556
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,224
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,267
    Karl Seguin [MVP]
    Mar 8, 2006
  4. dcabanis
    Replies:
    0
    Views:
    837
    dcabanis
    Oct 22, 2009
  5. Elmar
    Replies:
    14
    Views:
    1,179
    Elmar
    Jan 11, 2012
Loading...

Share This Page