On Wed, Mar 17, 2010 at 10:14 PM, Andreas J. Koenig
<andreas.koenig.7os6v...@franz.ak.mind.de> wrote:
>  > If someone can suggest a lightweight alternative to generate ISO 8601
>  > timestamps, that works too.  I'm not adverse to putting it inline
>  > using regular list form of gmtime if someone wants to volunteer some
>  > code.  (Time::Piece was a handy shortcut.)
>
> Maybe something like
>
>  use POSIX qw(strftime);
>  print strftime "%FT%TZ", gmtime;
>
> is good enough?

Ick.  POSIX.  That's heavy. Thinking about it, in UTC it should be
easy.  I suspect this will do:

  my ($year,$month,$day,$hour,$min,$sec) = (gmtime)[5,4,3,2,1,0];
  print sprintf("%4d-%02d-%02dT%02d:%02d:%02dZ",
    1900+$year,1+$month,$day,$hour,$min,$sec);

Anyone see any issues with that?

-- David

Reply via email to