On Tuesday, 2 December 2014 at 19:21:35 UTC, Steven Schveighoffer
wrote:
On 12/2/14 2:14 PM, Steven Schveighoffer wrote:
Not an oversight.
Date.add and Date.roll are for adding units that are variable.
For example, how many days are in a month? Answer: depends on
the month.
How many days in a year? Answer: depends on the year.
But days are NOT variable, there are exactly 24 hours in a
day. So to
add a day, you just add a day with +=.
Aaaand to expand on this, since roll *does* support days, it's
because the number being added isn't the important unit, it's
the unit above. Hence rolling days means you will stay in the
same month.
I'm not exactly sure of the reason behind roll, but I'm sure
Jonathan has one :)
-Steve
Oh well, this explanation make so much sense !
Unfortunately, I was not able to find it on the documentation :/
Thank you.