Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 36406
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: magno_yu [...] ml.com
Cc:
AdminCc:

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



Subject: is there a bug in _normalize_nanoseconds_?
I probably are not using it correctly.. but if I do: my $a = DateTime->new( year => 2007, month => 3, day => 15, hour => 9, minute => 30, second => 0, nanosecond => 880 * 1000); my $b = DateTime->new( year => 2007, month => 3, day => 15, hour => 9, minute => 30, second => 1, nanosecond => 0); my $d = $b - $a; $d->in_units('nanoseconds'); in debugger: x $d 0 DateTime::Duration=HASH(0x8981c04) 'days' => 0 'end_of_month' => 'wrap' 'minutes' => 0 'months' => 0 'nanoseconds' => 999120000 'seconds' => 0 I was expecting 120000 nanoseconds.. in _normalize_nanoseconds, we start off with: $seconds = 1; $nanoseconds = -880000; my $seconds = $self->{seconds} + $self->{nanoseconds} / MAX_NANOSECONDS; -> gives 0.99988 $self->{seconds} = int( $seconds ); -> gives 0 $self->{nanoseconds} = $self->{nanoseconds} % MAX_NANOSECONDS; -> gives 999120000 $self->{nanoseconds} -= MAX_NANOSECONDS if $seconds < 0; -> this guy will never get run... Am I missing something? Thanks! - Mag
Subject: Re: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_?
Date: Tue, 3 Jun 2008 22:35:12 +0200
To: bug-DateTime [...] rt.cpan.org
From: "Flavio S. Glock" <fglock [...] gmail.com>
2008/6/3 magno via RT <bug-DateTime@rt.cpan.org>: Show quoted text
> > nanosecond => 880 * 1000);
that's 0.00088 seconds Show quoted text
> 'nanoseconds' => 999120000
looks good - note that 1 second is 1E9 nanoseconds (1 000 000 000) - Flavio S. Glock
Subject: RE: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_?
Date: Tue, 3 Jun 2008 16:38:15 -0400
To: <bug-DateTime [...] rt.cpan.org>
From: "Yu, Magno \(Electronic Trading\)" <magno_yu [...] ml.com>
But that difference between those 2 times should be 12000 nano seconds? But it's outputting 99912000 nano seconds... Am I missing something? Thanks! - Mag Show quoted text
-----Original Message----- From: Flavio S. Glock via RT [mailto:bug-DateTime@rt.cpan.org] Sent: Tuesday, June 03, 2008 4:36 PM To: Yu, Magno (Electronic Trading) Subject: Re: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_? <URL: http://rt.cpan.org/Ticket/Display.html?id=36406 > 2008/6/3 magno via RT <bug-DateTime@rt.cpan.org>:
> > nanosecond => 880 * 1000);
that's 0.00088 seconds
> 'nanoseconds' => 999120000
looks good - note that 1 second is 1E9 nanoseconds (1 000 000 000) - Flavio S. Glock -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. --------------------------------------------------------
Subject: Re: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_?
Date: Tue, 3 Jun 2008 22:47:48 +0200
To: bug-DateTime [...] rt.cpan.org
From: "Flavio S. Glock" <fglock [...] gmail.com>
2008/6/3 magno via RT <bug-DateTime@rt.cpan.org>: Show quoted text
> But that difference between those 2 times should be 12000 nano seconds? > > But it's outputting 99912000 nano seconds... Am I missing something?
with "nano" seconds: 1.000 000 000 - 0.000 880 000 -------------------- 0.999 120 000 with "milli" seconds you'd get: 1.000 000 - 0.880 000 -------------- 0.120 000
Subject: Re: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_?
Date: Tue, 3 Jun 2008 22:48:36 +0200
To: bug-DateTime [...] rt.cpan.org
From: "Flavio S. Glock" <fglock [...] gmail.com>
2008/6/3 Flavio S. Glock <fglock@gmail.com>: Show quoted text
> > with "milli" seconds you'd get:
I mean, "micro"
Subject: RE: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_?
Date: Tue, 3 Jun 2008 16:51:09 -0400
To: <bug-DateTime [...] rt.cpan.org>
From: "Yu, Magno \(Electronic Trading\)" <magno_yu [...] ml.com>
O yes.... I am silly... Thanks! - Mag Show quoted text
-----Original Message----- From: Flavio S. Glock via RT [mailto:bug-DateTime@rt.cpan.org] Sent: Tuesday, June 03, 2008 4:49 PM To: Yu, Magno (Electronic Trading) Subject: Re: [rt.cpan.org #36406] is there a bug in _normalize_nanoseconds_? <URL: http://rt.cpan.org/Ticket/Display.html?id=36406 > 2008/6/3 Flavio S. Glock <fglock@gmail.com>:
> > with "milli" seconds you'd get:
I mean, "micro" -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. --------------------------------------------------------
Thanks for answering this, Flavio. Marking resolved ...