Adding days to std.datetime.Date
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 2 11:14:58 PST 2014
On 12/2/14 2:00 PM, H. S. Teoh via Digitalmars-d-learn wrote:
> On Tue, Dec 02, 2014 at 06:49:54PM +0000, via Digitalmars-d-learn wrote:
>>> But still, why this method
>>> http://dlang.org/phobos/std_datetime.html#.Date.add only supports "month"
>>> or "years" while this one
>>> http://dlang.org/phobos/std_datetime.html#.Date.roll does ?
>>
>> But still, why this method
>> http://dlang.org/phobos/std_datetime.html#.Date.add only supports
>> "month" or "years" while this one
>> http://dlang.org/phobos/std_datetime.html#.Date.roll does support days
>> ?*
>
> Hmm. Looks like an oversight. File a bug?
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 +=.
-Steve
More information about the Digitalmars-d-learn
mailing list