Hello,

I think that the parse functions of DateTime::Format::Duration do not
parse the nanoseconds correctly.

Here an example:

---
use strict;
use warnings;

use DateTime::Duration;
use DateTime::Format::Duration;

my $f = DateTime::Format::Duration->new(pattern => '%M:%S,%2N',
                                        normalise => 1);

my $dur = $f->parse_duration("34:48,14");
my %deltas = $f->parse_duration_as_deltas("34:48,14");

print $dur->nanoseconds; # 14 --> I'd expect 140000000
print "\n";
print $deltas{nanoseconds}; # 14 --> I'd expect 140000000
print "\n";

print $f->format_duration($dur);
print "\n";
---

The parse functions store the value 14 nanoseconds in the
DateTime::Duration object. But in my opinion it should be 140000000. Is
this a bug or am I understanding something wrong?

I also tried the parse function of "DateTime::Format::Strptime". It's
the same concept but with a DateTime object instead of a
DateTime::Duration object. This parse function is parsing the
nanoseconds as I expect it, i.e. 140000000.

---
use strict;
use warnings;

use DateTime::Format::Strptime;
my $Strp = new DateTime::Format::Strptime(pattern => '%M:%S,%2N' );
my $dt = $Strp->parse_datetime('34:48,14');
print $dt->nanosecond; # 140000000 --> correct
---

Thank you for your help
Dirk


Reply via email to