digitalmars.D.learn - Add a duration (in Days) to a Date
- Mil58 (19/19) Nov 13 2019 Hi all...
- Adam D. Ruppe (3/5) Nov 13 2019 just use the plus operator
Hi all...
In the following example, i would to add the "diff" value (in
days) to a certain date (or the today's date "auj") >>
import std.stdio;
import std.datetime;
import core.time : Duration;
void main()
{
auto deb = DateTime(2019, 9, 5);
auto auj = Clock.currTime();
writeln("Aujourd'hui : ", auj.day, " ", auj.month, " ",
auj.year);
writeln("Le début : ", deb.day, " ", deb.month, " ", deb.year);
Duration diff = cast(DateTime) auj - deb;
auto ecart = diff.total!"days" + 1;
writeln("Diff : ", diff.total!"days" + 1);
writeln(ecart);
}
Thanks for replies...
Nov 13 2019
On Wednesday, 13 November 2019 at 17:23:42 UTC, Mil58 wrote:In the following example, i would to add the "diff" value (in days) to a certain date (or the today's date "auj") >>just use the plus operator auto newTime = Clock.currTime() + 5.days
Nov 13 2019








Adam D. Ruppe <destructionator gmail.com>