Adding days to std.datetime.Date
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 2 11:21:35 PST 2014
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
More information about the Digitalmars-d-learn
mailing list