On Sunday, 29 November 2015 at 23:52:05 UTC, anonymous wrote:
You can add a Duration to a DateTime, giving you a new DateTime. And you can subtract a DateTime from another, giving you the Duration between them.

Example:
----
import std.datetime, std.stdio;
void main()
{
    DateTime oldYear = DateTime(2015, 12, 31, 23, 59, 59);
    writeln(oldYear); /* 2015-Dec-31 23:59:59 */
DateTime newYear = oldYear + 1.seconds; /* adding Duration to DateTime */
    writeln(newYear); /* 2016-Jan-01 00:00:00 */
Duration diff = newYear - oldYear; /* subtracting DateTime from DateTime */
    writeln(diff); /* 1 sec */
}
----

Thanks. I'll add these as examples.

Reply via email to