On Tuesday, 2 December 2014 at 18:00:14 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Tue, Dec 02, 2014 at 05:21:27PM +0000, via
Digitalmars-d-learn wrote:
On Thursday, 7 April 2011 at 19:10:40 UTC, Piotr Szturmaj
wrote:
>Is it possible to add a particular number of days to a Date?
>
>I have number of days since 1 Jan 2000 and I want to convert
>it to
>Date:
>
>int days = read!int; // number of days since 1 Jan 2000
>Date x = Date(2000, 1, 1);
>x.add!"days"(days);
>
>Unfortunately add() does not support adding days. Will it be
>possible
>in the future or is there another approach?
>
>Thanks
Is there any particular reason why std.datetime's "add" does
not
support days ?
Sure it does:
import std.datetime;
import std.stdio;
void main() {
auto date = Date(2000, 1, 1);
date += 10.days;
writeln(date);
}
Output:
2000-Jan-11
T
Indeed, thank you :)
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 ?