6 use DateTime::Format::Duration;
7 use DateTime::Duration;
10 my $iso8601_rx = qr{^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$};
12 my $json = JSON::XS->new->utf8;
14 my $dur_fmt = DateTime::Format::Duration->new(
17 q{{"week":"%V","day":"%u","hour":"%k","minute":"%M","second":"%S"}}
21 my ( $now, $src ) = @_;
23 print STDERR "Computing duration between [$src] and [$now]\n";
26 @now{qw(year month day hour minute second)} = ( $now =~ $iso8601_rx );
27 @src{qw(year month day hour minute second)} = ( $src =~ $iso8601_rx );
29 print $dur_fmt->format_duration_from_deltas(
30 DateTime->new(%now)->subtract_datetime_absolute( DateTime->new(%src) )