Hello!

I have a problem with DateTime::set_time_zone("local") call: it says that
cannot determine local timezone. Actually, this behavior appeared when I
upgraded DateTime modules (and relatves). After little investigation I found
that since v0.12 (that I used before) there was changed local timezone
determination algorithm and, the following lines are disappeared:

 

            my @t = gmtime;

 

            my $local = Time::Local::timelocal(@t);

            my $gm    = Time::Local::timegm(@t);

 

            return

                DateTime::TimeZone::OffsetOnly->new

                    ( offset => offset_as_string( $gm - $local ) );

 

What was the reason of cutting off that method? Yes, there are several new
methods of local timezone determination appeared, but all of them applicable
only under UNIX systems. Unfortunately, my script should work under Windows
and, therefore, I have lost a chance to determine local timezone. The only
way left under Windows is to use environment variable, but this method
scarcely applicable for me too: the script will be used by customer and I
can't guarantee that TZ variable always will be set properly. For the
moment, I used a "hack" - I added several strings to
DateTime::TimeZone::Local:

 

sub local_time_zone

{

    my $tz;

 

    foreach ( qw( _from_env _from_etc_localtime _from_etc_timezone

                  _from_etc_sysconfig_clock _old_plain) )

    {

            $tz = __PACKAGE__->$_();

            return $tz if $tz;

    }

 

    die "Cannot determine local time zone\n";

}

 

sub _old_plain

{

  my @t = gmtime;

 

  my $local = Time::Local::timelocal(@t);

  my $gm    = Time::Local::timegm(@t);

 

  return

      DateTime::TimeZone::OffsetOnly->new

          ( offset => DateTime::TimeZone::offset_as_string( $gm - $local )
);

}

 

Could anybody suggest a more suitable way? Or, maybe, just add something
like I wrote above into DateTime::TimeZone::Local?

 

                       Best regards, Elliot.

 

----------------------------------------------------------------------------
-------------------
Ilya A. Tereshchenko
Developer

Aurorisoft Inc.

 

E-mail: [EMAIL PROTECTED]
For more visit http://www.aurorisoft.com/ <http://www.novosoft-usa.com/> 
----------------------------------------------------------------------------
------------------- 

 

Reply via email to