Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Date::Manip and daylight savings

by sparkyichi (Deacon)
on Nov 07, 2011 at 17:30 UTC ( #936547=note: print w/replies, xml ) Need Help??

in reply to Date::Manip and daylight savings

I have not looked at the DateTime module and it has been a very long time sense I’ve gone through the Date::Manip Modules. However if I was encoding it I would probably handle the problem by subtracting a day from epoch either by coding daylight saving time in my application (bad as it will not be dynamic) if I thought I could reliable predicts when it is going to be. However, day light savings time can be affected by politics like what happened in Russia. I would recommend looking for a reliable source for Time Zone information something like an Atomic Clock from a government web site and write my application to pull the data from the source and make your own calculations.

Sorry I don’t have any specific code for you, but I hope I gave you some ideas…


Replies are listed 'Best First'.
Re^2: Date::Manip and daylight savings
by SBECK (Hermit) on Nov 07, 2011 at 18:09 UTC

    You could do that (look for a reliable source of timezone data) of course... but it's already been done twice: Date::Manip and DateTime. I wouldn't suggest that as a good idea to anyone not interested in the timezone problem itself.

    There ARE perfectly valid reasons to reinvent this wheel (after all, I did just that with Date::Manip) but they are mostly about trying to improve the wheel, or learning how the wheel works. If that's you're level of interest... by all means, write your own timezone code. If you're not interested in the wheel itself (just need to use the data)... use one of the existing modules. The rules for Daylight Saving are way too complicated to do it yourself.

      So when I choose to use a module I first read the documentation and the first thing I read is “Time zone support is extremely limited, and is often broken.” Then I write my code and it doesn’t work. I tend to look for ways on how I can write my code to make it work. It is NOT “reinventing the wheel” when your wheel is broken.

      If you did what the poster is asking then post your code (which I saw you did, nice example) or explain how you did it. It helps no one when you cry about people resorting to writing code when they couldn’t get a module to do what they wanted to.


        If you'll read the full document, you'll see that the excerpt that you quote applies specifically to version 5 of Date::Manip (and it is true... timezone support WAS very limited and broken). The statement does not apply to version 6.

        I'm not sure where you get that I was 'crying about people resorting to writing code'. My response to your comment was not meant to be complaining or derogatory. I was simply saying that I don't believe that people should tackle the problem of daylight saving time as part of their coding project. It's so complicated (made especially so due to the fact that there are no rigid rules for saving time... they are assigned by arbitrary shifts in the views of people) that it's almost impossible to do quickly AND right. If you need daylight saving time support in your code, and you're not intensely interested in that particular problem... don't bother writing your own. Use one of the existing modules.

        A more complete reading of the Date::Manip documentation, or of the DateTime::Timezone module should reveal that both are equipped to deal with the problem.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://936547]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-06-21 05:45 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.