Skip Menu |

This queue is for tickets about the DateTime-Format-Duration CPAN distribution.

Report information
The Basics
Id: 47764
Status: open
Priority: 0/
Queue: DateTime-Format-Duration

People
Owner: Nobody in particular
Requestors: simon [...] mailguard.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: DateTime::Format::Duration bug
Date: Fri, 10 Jul 2009 12:31:59 +1000
To: bug-DateTime-Format-Duration [...] rt.cpan.org
From: Simon Cocking <simon [...] mailguard.com.au>
$ perl -v This is perl, v5.8.8 built for darwin-thread-multi-2level $ perl -MDateTime::Format::Duration -le 'print $DateTime::Format::Duration::VERSION' 1.03 Taking the sample code from the CPAN documentation: #!/usr/bin/perl use strict; use warnings; use DateTime; use DateTime::Duration; use DateTime::Format::Duration; my $d = DateTime::Format::Duration->new( pattern => '%Y years, %m months, %e days, '. '%H hours, %M minutes, %S seconds' ); print $d->format_duration( DateTime::Duration->new( years => 3, months => 5, days => 1, hours => 6, minutes => 15, seconds => 45, nanoseconds => 12000 ) ); Is supposed to output: # 3 years, 5 months, 1 days, 6 hours, 15 minutes, 45 seconds Actually outputs: # 0 years, 41 months, 1 days, 00 hours, 375 minutes, 45 seconds Simon Cocking Director of Technology MailGuard: Protection | Productivity | Profit 2006 | 2007 Deloitte Technology Fast 500 Winner - Asia Pacific P: 1300 30 44 30 F: 03 9011 6110 W: www.mailguard.com.au E: simon@mailguard.com.au -- MailGuard | http://www.mailguard.com.au/about-us Australian Owned and Locally Supported Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering. http://www.mailguard.com.au/mg
I'm getting a similar problem with the following code: {{{ #!/usr/bin/perl use strict; use warnings; use DateTime; use DateTime::Format::Duration; my $s = DateTime->from_epoch(epoch => 1278489355.275070); my $e = DateTime->from_epoch(epoch => 1278499223.541360); my $fmt = DateTime::Format::Duration->new( pattern => '%H hours, %M minutes, %S seconds' ); print $fmt->format_duration($e - $s), "\n"; }}} It prints {{ 00 hours, 164 minutes, 28 seconds }}. Regards, -- Shlomi Fish
From: ozcoder [...] gmail.com
Hi Shlomi, You forgot to add the normalize flag. See debug run at bottom. Gordon On Sat Jul 10 02:25:43 2010, SHLOMIF wrote: Show quoted text
> I'm getting a similar problem with the
following code: Show quoted text
> > {{{ > #!/usr/bin/perl > > use strict; > use warnings; > > use DateTime; > use DateTime::Format::Duration; > > my $s = DateTime->from_epoch(epoch => 1278489355.275070); > my $e = DateTime->from_epoch(epoch => 1278499223.541360); > > my $fmt = > DateTime::Format::Duration->new( > pattern => '%H hours, %M minutes, %S seconds' > ); > > print $fmt->format_duration($e - $s), "\n"; > }}} > > It prints {{ 00 hours, 164 minutes, 28 seconds }}. > > Regards, > > -- Shlomi Fish
DB<1> main::(t.pl:18): my $fmt = DateTime::Format::Duration->new( main::(t.pl:19): normalize => 1, main::(t.pl:20): pattern => '%H hours, %M minutes, %S seconds'); DB<1> main::(t.pl:22): print $fmt->format_duration($e - $s), "\n"; DB<1> 02 hours, 44 minutes, 28 seconds