http://www.perlmonks.org?node_id=1163523


in reply to DateTime and ISO8601

This is not precisely what you are looking for, but I'll offer it as an alternative.

I found the same problem when I was adding support for ISO8601 dates to Date::Manip, and I wanted to find out which fields had been set.

Date::Manip (which will parse all of the ISO8601 dates) has a method (complete) which will tell you what fields were explicitly added, and which are implied. So you end up with:

use Date::Manip::Date; my $obj = new Date::Manip::Date; $obj->parse("2000-06-01-00:00"); print $obj->value(),"\n"; print $obj->complete('h'),"\n"; print $obj->complete('m'),"\n"; print $obj->complete('s'),"\n";
prints:
2000060100000 1 1 0
So, if you can't get DateTime to do it, you may want to look at Date::Manip.

Replies are listed 'Best First'.
Re^2: DateTime and ISO8601
by philkime (Beadle) on May 19, 2016 at 20:47 UTC
    Ah, thank you, last time I looked at Date::Manip, I don't think ->complete() was in there. The tricky part is that I need DateTime's era (BC/AD etc) output support.