Add a duration (in Days) to a Date

Mil58 peter_pinkness at yahoo.fr
Wed Nov 13 17:23:42 UTC 2019


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...


More information about the Digitalmars-d-learn mailing list