That is exactly what I was looking for. Unfortunately, it doesn't recognize all of the time zone specifiers.

Example:

use Time::Piece; my $pubdate = "Thu, 11 Jun 2009 11:50:00 PDT"; my $t = Time::Piece->strptime( "Thu, 11 Jun 2009 11:50:00 PDT", " +%a, %d %b %Y %H:%M:%S %Z" ); my $offset = $t->tzoffset; printf( "%s\n", $t ); printf( "%s\n", $t->tzoffset->seconds );
results in
ghodmode@home:perl ] ./timepiece.pl
garbage at end of string in strptime: PDT at /usr/lib/perl/5.10/Time/Piece.pm line 470.
Thu Jun 11 11:50:00 2009
0

I think I'm going to rely on the call to the shell's date for now. Later, if I want to make the program more portable, I'll probably just create a hash with a short list of time zone specifiers to convert them to the appropriate numeric offset. That would break if the program encountered a new zone, but it would work for my purposes.

Of course Date::Time is the right way to do it, but it's less portable because of the external dependency.

I like Time::Piece, though. I didn't know about this module and I anticipate using it a lot more in the future.

--
-- Ghodmode
Blessed is he who has found his work; let him ask no other blessedness.
-- Thomas Carlyle

In reply to Re^4: RFC 822 date manipulation without DateTime module? by GhodMode
in thread RFC 822 date manipulation without DateTime module? by GhodMode

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.