Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: RFC 822 date manipulation without DateTime module?

by GhodMode (Pilgrim)
on Jun 12, 2009 at 12:51 UTC ( [id://770943]=note: print w/replies, xml ) Need Help??


in reply to Re: RFC 822 date manipulation without DateTime module?
in thread RFC 822 date manipulation without DateTime module?

When you mentioned it, I thought that strptime was exactly what I was looking for, but it's not actually part of the core POSIX module. It's just an extension.

XML::FeedPP doesn't allow the text representation of the time zone, so it wouldn't solve this particular problem. It would save me a lot of effort if I had started with something like this, but I'm doing this more to learn how to program around an RSS/podcast feed than to actually get the job done.

My main goal when I asked this question was to avoid introducing additional dependencies on the program rather than just to avoid DateTime. So, I'm not really looking for another module to do the job. I think that the answer is that Perl doesn't have this feature.

Thank you.

--
-- Ghodmode
Blessed is he who has found his work; let him ask no other blessedness.
-- Thomas Carlyle
  • Comment on Re^2: RFC 822 date manipulation without DateTime module?

Replies are listed 'Best First'.
Re^3: RFC 822 date manipulation without DateTime module?
by Anonymous Monk on Jun 12, 2009 at 21:41 UTC

      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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found