Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Help with date:manip

by SBECK (Chaplain)
on May 10, 2016 at 13:00 UTC ( [id://1162625]=note: print w/replies, xml ) Need Help??


in reply to Help with date:manip

A few notes:

First off, I see that I definitely need to improve my manual. It's not obvious, if you go right to the https://metacpan.org/pod/Date::Manip::Config document that you can set config variables in two ways. Using the form:

    $date->config("VAR","VAL");
is for the OO interface.  Using the call:
    Date_Init("VAR=VAL");
is the functional method (and is described in the https://metacpan.org/pod/Date::Manip::DM6 document. I will clarify the Config document to mention both in order to avoid this confusion. Sorry for that.

Second, the TZ variable is deprecated, as you note, and will be removed the next release I believe, so you definitely want to use the SetDate config variable.

Third, you did find a bug because "EST" should have returned a timezone (possibly not the one you want) since it is a valid abbreviation, and abbreviations should be parsed as timezones too. I'm in the process of correcting that bug and it'll be fixed in the next release. To be clear, the call:

   Date_Init("SetDate=now,EST");
should have worked (though it would not have produced the correct timezone as described in my next point).

Finally, using EST as a timezone (as was suggested by others) can lead to unpredictable results. For example, I'm in the America/New_York timezone, and if I set TZ=EST (or the equivalent SetDate=now,EST), it sets the timezone to be the America/Panama timezone, because it returns a timezone for which the abbreviation is currently EST. Since the abbreviation is currently EDT in the America/New_York timezone, America/New_York will not be used. As others have suggested, you really want to set the timezone unambiguously using a full timezone name. If you were to use SetDate=DATE,EST it would choose a timezone where EST was the abbreviation on DATE.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found