Balázs Szabó (dLux) wrote:
Hi,
Hello,
I am the author of the Class::Date module, which can be found in CPAN,
and i had a complaint about timezone handling in perl.
I tried to debug it, and I have found that mod_perl uses the TZ
environment somehow differently.
What I did in my module is the following:
delete $ENV{TZ};
tzset();
($a, $b) = tzname();
$a should contain the local timezone (according to the documentation of
Oi! nor sure where to start,
1)
use strict;
use warnings;
2) don't use $a and $b
- they are special
- they are super ambiguouse
3) use good names so you and we know what you're smoking...
> delete $ENV{TZ};
> tzset();
POSIX POD: "tzset() for setting the current timezone based on the
environment variable TZ"
If you just deleted it how can it use it?
> ($a, $b) = tzname();
my($standard_timezone, $summer_timezone) = tzname();
the tzset manual), although it is UTC always. What I suspect is that
when I delete the TZ variable from the environment, it does not really
delete it.
How I can make sure that this variable is deleted?
if(defined $ENV{TZ}) {
print "TZ: $ENV{TZ}\n";
}
else {
print "TZ is not defined in my ENV\n";
}
maybe check the system's with `printenv`...
Do you know any other way to get the timezone which is guessed by
tzset() in case of the TZ environment variable does not work?
`man tzset` says:
If TZ does not appear in the environment, the best available
approxima-
tion to local wall clock time, as specified by the
tzfile(5)-format file
/etc/localtime is used.
If TZ appears in the environment but its value is a null string,
Coordi-
nated Universal Time (UTC) is used (without leap second correction).
If TZ appears in the environment and its value begins with a colon
(`:'),
the rest of its value is used as a pathname of a tzfile(5)-format file
from which to read the time conversion information. If the first
charac-
ter of the pathname is a slash (`/') it is used as an absolute
pathname;
otherwise, it is used as a pathname relative to the system time
conver-
sion information directory.
If its value does not begin with a colon, it is first used as the
path-
name of a file (as described above) from which to read the time
conver-
sion information. If that file cannot be read, the value is then
inter-
preted as a direct specification (the format is described below)
of the
time conversion information.
If the TZ environment variable does not specify a tzfile(5)-format
file
and cannot be interpreted as a direct specification, UTC is used.