Merge pull request #3847 from bachmeil/change-datetime

Documentation: Added example to DateTime opBinary and reference to core.time.Duration
This commit is contained in:
Brian Schott 2015-12-01 16:09:16 -08:00
commit ef45b5e542

View file

@ -6173,7 +6173,7 @@ public:
)
Params:
duration = The duration to add to or subtract from this
duration = The $(CXREF time, Duration) to add to or subtract from this
$(LREF SysTime).
+/
SysTime opBinary(string op, D)(in D duration) @safe const pure nothrow
@ -6194,6 +6194,14 @@ public:
return retval;
}
///
unittest
{
auto oldYear = SysTime(DateTime(2015, 12, 31, 23, 59, 59));
auto newYear = oldYear + 1.seconds;
assert(newYear == SysTime(DateTime(2016, 1, 1, 0, 0, 0)));
}
unittest
{
auto st = SysTime(DateTime(1999, 7, 6, 12, 30, 33), hnsecs(2_345_678));
@ -16151,7 +16159,7 @@ public:
)
Params:
duration = The duration to add to or subtract from this
duration = The $(CXREF time, Duration) to add to or subtract from this
$(LREF DateTime).
+/
DateTime opBinary(string op, D)(in D duration) @safe const pure nothrow
@ -16171,6 +16179,14 @@ public:
mixin(format(`return retval._addSeconds(convert!("hnsecs", "seconds")(%shnsecs));`, op));
}
///
unittest
{
auto oldYear = DateTime(2015, 12, 31, 23, 59, 59);
auto newYear = oldYear + 1.seconds;
assert(newYear == DateTime(2016, 1, 1, 0, 0, 0));
}
unittest
{
auto dt = DateTime(Date(1999, 7, 6), TimeOfDay(12, 30, 33));