This terrific stuff— Types::DateTime, tobyink—is going into something I’m working on. Out of the box it is parsing perfectly–
use 5.12.0;
package CowTime {
use Moo;
use Types::DateTime -all;
has timestamp =>
is => "ro",
isa => DateTimeUTC->plus_coercions( Format['ISO8601'] ),
coerce => 1;
1;
};
my $original = "2019-12-07T00:07:40.587596283-05:00";
my $cowtime = CowTime->new( timestamp => $original );
say $original;
say $cowtime->timestamp->time_zone;
say $cowtime->timestamp->nanosecond;
say $cowtime->timestamp;
__END__
2019-12-07T00:07:40.587596283-05:00
2019-12-07T05:07:40
DateTime::TimeZone::UTC=HASH(0x7f9e85ba3cd0)
587596283
It’s pulling apart the input perfectly but the output is the standard format and I’m looking for the “extended” format of the input such that the stringification will roundtrip to the form with the offset and the nanoseconds. I was set to code dive and look for the formatting hooks but I thought this was a really interesting package and wanted to put it up here. Also, I am lazy.