http://www.perlmonks.org?node_id=1162625


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.