I am trying to work with date strings formatted as:
YYYY-MM-DDThh: mm: ss
The strftime format for generating this line is %FT%T:
perl -MPOSIX=strftime -E 'say strftime q{%FT%T}, localtime;'
But when I try to parse this line with Time :: Piece :
perl -MPOSIX=strftime -MTime::Piece -E '
say strftime q{%FT%T}, localtime;
Time::Piece->strptime( strftime(q{%FT%T}, localtime), q{%FT%T});
'
I got this error:
2013-11-15T17: 32: 58
Error parsing time at /usr/local/lib/perl/5.14.2/Time/Piece.pm line 469.
Or if I try this:
perl -MPOSIX=strftime -MTime::Piece -E 'Time::Piece->strptime(strftime(q{%F}, localtime), q{%F});'
I got it:
garbage at end of string in strptime: 2013-11-15 at /usr/local/lib/perl/5.14.2/Time/Piece.pm line 469.
The man says that %Fis the ISO8601 date format in strptime and strftime. Is strptime true backwards compatible with strftime?
source
share