The difference between the dates in years
Steven Schveighoffer
schveiguy at gmail.com
Sun Feb 11 02:31:47 UTC 2024
On Saturday, 10 February 2024 at 23:48:56 UTC, Jonathan M Davis
wrote:
> If I understand correctly, he cares about how far into the
> month the dates
> are, whereas diffMonths ignores the smaller units, meaning that
> you get the
> same result no matter when in the month the dates are. So,
> 2000-05-10 - 1990-05-09 would give 10, whereas 2000-05-10 -
> 1990-05-30
> would give 9. diffMonths / 12 would give 10 in both cases.
I thought `diffMonths` was actually already taking this into
account...
Looking at the impl, it's pretty simple.
Would it make sense to have an overload that takes into account
the day as well as the month/year? This kind of stuff is
sometimes tricky to get right.
-Steve
More information about the Digitalmars-d-learn
mailing list