So I have these two DateTime objects, and I subtract them to get an interval. Great! Now I want to find out how long that interval is in minutes.
Uh, you can't, because my interval spans nearly three days' worth of time. And since in some weird edge cases a day might not equal 24 hours, DateTime::Interval therefore provides no method at all for letting me get the length of my interval in minutes making standard assumptions.
annoying workaround (Score:2)
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
DateTime::Duration does not DWIM (Score:1)
You might want to consider something along these lines.
use strict;
use warnings;
use DateTime;
use DateTime::Format::Duration;
use Data::Dumper;
my $dt1 = DateTime->now(
time_zone => 'UTC',
);
my $dt2 = DateTime->new(
year => 2006,
month => 10,
day => 31,
time_zone =>'UTC',
);
my $delta = $dt1-
DateTime::Format::Duration (Score:2)
Re:DateTime::Format::Duration (Score:2)
The last time I checked (this morning), it did not do what I wanted. It could tell me the minutes component of the interval, but it could not convert the days, hours, and minutes to a total number of minutes. Unless I'm missing something, and if so, please point it out, because you will really help me.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:DateTime::Format::Duration (Score:1)
Re:DateTime::Format::Duration (Score:2)
Yes, I did, and thank you! I'd discovered delta_ms by that time. However, it still does not really DWIM. If I have real Date objects, I should be able to subtract them and get an interval that can be converted to whatever resolution or units I want. The problem then is that I have to do something unintuitive with my DateTimes: intuitively, I had written
and expected to get something that I could express as minutes. I shouldn't have to perform something other than subtraction in order to
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:DateTime::Format::Duration (Score:2)