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.


In reply to Re: Help with date:manip by SBECK
in thread Help with date:manip by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.