Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > DateTime.pm and midnight

Reply
Thread Tools

DateTime.pm and midnight

 
 
Arvin Portlock
Guest
Posts: n/a
 
      12-29-2005
Why does the following code return 0 minutes instead of 60?

use DateTime;
use DateTime:uration;

my $year = 1969;
my $month = 4;
my $day = 2;
my $hour = 23;

my $datetime = new DateTime (year => $year,
month => $month,
day => $day,
hour => $hour);

my $onehour = new DateTime:uration (hours => '1');

my $elevenpm = new DateTime (year => $year,
month => $month,
day => $day,
hour => '23');

my $midnight = $elevenpm + $onehour;

my $delta = $midnight - $datetime;
print $delta->minutes, "\n";


 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      12-30-2005
Arvin Portlock wrote:
> Why does the following code return 0 minutes instead of 60?
>
> use DateTime;
> use DateTime:uration;
>
> my $year = 1969;
> my $month = 4;
> my $day = 2;
> my $hour = 23;
>
> my $datetime = new DateTime (year => $year,
> month => $month,
> day => $day,
> hour => $hour);
>
> my $onehour = new DateTime:uration (hours => '1');
>
> my $elevenpm = new DateTime (year => $year,
> month => $month,
> day => $day,
> hour => '23');
>
> my $midnight = $elevenpm + $onehour;
>
> my $delta = $midnight - $datetime;
> print $delta->minutes, "\n";


Because it's 1 hour and 0 minutes difference. Minutes are 0-59.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datetime.time and midnight Ethan Furman Python 6 02-22-2009 09:20 PM
Remove Object From Cache at Midnight Jordan Richard ASP .Net 2 04-30-2005 08:35 PM
Re: Midnight Club II Nissan Skyline meanoldman MCSE 0 02-28-2005 05:55 PM
New series of Midnight Movie double features? karlpov DVD Video 8 08-22-2004 02:05 PM
Re: Anyone know anything about Chimes At Midnight? ecconando@hotmail.com DVD Video 1 08-16-2003 10:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57