@dsteinbrunner: "Hello,
In working with durations I have found that just getting the number of
days for a duration is not possible.  I am given the impression that
in_units('days') will give me the result I'm looking for but that is not
that case.  I have created a small bit of code that shows the issue I'm
having:
use strict;
use DateTime;
my $dt = DateTime->now();
foreach ( 0 ... 100 ) {
    my $later    = $dt->clone->add(days => $_);
    my $duration = $later - $dt;
    print $duration->in_units('days') . "\n";
}
The results cycle from 0 to 30 rather than simply going from 0 to 100 as I
would expect.  When I look back at the docs I see confirmation of my
expectations with the following example:
$dur->in_units( 'months' );           # 27
This shows that years, which is a greater increment, is not interfering
with the results as in the case with months and days in my example.  To
confirm the example in the docs all you have to do it change the two
occurrences of "days" in my example code to "months" and you will find the
results to be 0 through 100.
So are my expectations incorrect or is this a bug?  If this is not a bug,
is there a way to just get the days that I'm not seeing?
Thanks,
David Steinbrunner"
    @dsteinbrunner: "<quote>
Ok, a little more digging has been done so I'll follow up.
So I started thinking about how just calling the ->days method returns
days limited by week.  I don=B9t have the in my code example but all you
have to do is add a print to $duration->days in there to see what I mean.
This got me thinking about weeks and what is done for it compared to days
and months.  It turns out the results of ->in_units('weeks') and ->weeks
is exactly the same, 0 through 3.
So when calling ->months, ->weeks or ->days you get results limited to the
next highest interval but when using in_units for the same intervals each
has a different type of result.
Months: Not limited
Weeks:  Limited but the next interval (months)
Days:   Limited by two intervals (months)
Of course, the pattern here is that each of these are limited by months
but limiting months by months gives you the "right" answer so there is no
issue.
So that is it for now.  I'm assuming this is a bug but I'd appreciate
someone confirming my assumption.
David Steinbrunner"
    @jbjornstad: "David, et. al.,
This topic on the FAQ page is what you need:
=
<url>
_I_calculate_the_difference_in_days_between_dates_-11
The FAQ was misformatted and hid this topic.
I just edited it to remedy this.
Since the use of delta_days() (twice!) is so so unintuitive
I suggest another method in DateTime.pm called days_apart().
sub days_apart {
	my ($dt1, $dt2) =3D @_;
	return abs($dt1->delta_days($dt2)->delta_days());
}
DateTim888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Duration is deceptively complex.
It deals with a very difficult problem so it needs to be complex.
However, for most of us mere mortals who deal with normal everyday
date problems (and really don't care much about leap seconds)
we often want to know how many days separate
two dates.     These two lines result in very different =
DateTim888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Durations:
	my $dur1 =3D $dt1 - $dt2;
	my $dur2 =3D $dt1->delta_days($dt2);
(print them using DateTim888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Format888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4uration to see)
One's first instinct is to use the first method ( overloading - ) BUT
getting the number of days out of $dur1 is very very tricky.
I think the perldoc for DateTim888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Duration needs attention.
The difference between:
	$dur->days();
	$dur->delta_days();
	$dur->in_units('days');
is far from clearly explained.
Jon
<quote>
wrote:
as
interfering
To
find
bug,
you
mean.
days
->weeks
the
each
months
no"
{'source': 'USENET', 'other_information': '{"reply_count": 2, "forum_name": "perl.datetime.20141216.mbox"}', 'file': 'data/output/usenet-perl.datetime.parquet'}