On Thu, Oct 24, 2019 at 1:55 PM Mil58 via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > > Hi All... > I am desperate for the answer to the following problem: > to obtain the difference between the date of today and an older > date (results in days...) > > See my script below, where I would like to do: > "date of today" (var: auj) - "an older date" (var: deb) = xx days > > 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); > } > > Thanks in advance ! :-)
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); writeln("Diff in days : ", (cast(DateTime)auj - deb).total!"days"); }