Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Determining Daylight Savings Time

by maverick (Curate)
on May 29, 2002 at 21:31 UTC ( #170226=note: print w/ replies, xml ) Need Help??


in reply to Determining Daylight Savings Time

The first question that springs to mind is why do you need to know if the time zone you're in is daylight savings or not?

If the goal is to have two different systems in different timezones have a normalized time, why not use gmtime() instead of localtime()? it gives you the same value regardless of the local...

/\/\averick
OmG! They killed tilly! You *bleep*!!


Comment on Re: Determining Daylight Savings Time
Re: Re: Determining Daylight Savings Time
by Starky (Chaplain) on May 29, 2002 at 21:44 UTC
    Thanks for your reply!

    The reason is that I'm doing timezone conversion. The code is supposed to be high-availability ... it is very bad if times get snookered even a couple times a year.

    I'm using Date::Manip to perform the conversion. Date::Manip understands MST and MDT, but it does not understand something like MST7MDT. For example,

    #!/usr/bin/perl use strict; use Date::Manip; my $date = &ParseDate("2002-05-29 08:00:00"); print "The unconverted date is [".&UnixDate($date,"%Y-%m-%d %H:%M:%S") +."]\n"; my $from = 'MDT'; my $to = 'GMT'; my $converted = &Date_ConvTZ($date,$from,$to); print "The conversion from [$from] resulted in [".&UnixDate($converted +,"%Y-%m-%d %H:%M:%S")."]\n"; $from = 'MST7MDT'; $converted = &Date_ConvTZ($date,$from,$to); print "The conversion from [$from] resulted in [".&UnixDate($converted +,"%Y-%m-%d %H:%M:%S")."]\n";
    gives
    The unconverted date is [2002-05-29 08:00:00] The conversion from [MDT] resulted in [2002-05-29 14:00:00] The conversion from [MST7MDT] resulted in [2002-05-29 08:00:00]

    So I need to know whether a given date is in Mountain Daylight Time or Mountain Standard Time.

    Edit by tye to change PRE tags to CODE tags

      So essentially the problem is that Date::Manip doesn't understand MST7MDT and gives you GMT? Maybe you could look at the internals of Date::Manip and add that timezone? Perhaps a different CPAN module would do the trick...Date::Handler looks promising..

      HTH

      /\/\averick
      OmG! They killed tilly! You *bleep*!!


      Reason: (MeowChow) Nodereaper is coming for me... i can feel its presence... URAGHHHH!!!

      For more information on this node visit: this

      I'm fairly certain that Time::ParseDate correctly handles the AAAXBBB timezone format.

      Update: Whoops, I'm fairly certain I'm wrong.

         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://170226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (17)
As of 2014-07-30 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (239 votes), past polls