November 13, 2019 Add a duration (in Days) to a Date | ||||
---|---|---|---|---|
| ||||
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... |
November 13, 2019 Re: Add a duration (in Days) to a Date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mil58 | 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
|
Copyright © 1999-2021 by the D Language Foundation