View source code
Display the source code in std/datetime/date.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.datetime.date.TimeOfDay.roll
Adds the given number of units to this TimeOfDay
, mutating it. A
negative number will subtract.
The difference between rolling and adding is that rolling does not
affect larger units. For instance, rolling a TimeOfDay
one hours's worth of minutes gets the exact same
TimeOfDay
.
Accepted units are "hours"
, "minutes"
, and "seconds"
.
Parameters
Name | Description |
---|---|
units | The units to add. |
value | The number of units to add to this
TimeOfDay . |
Returns
A reference to the TimeOfDay
(this
).
Example
auto tod1 = TimeOfDay(7, 12, 0);
tod1 .roll!"hours"(1);
writeln(tod1); // TimeOfDay(8, 12, 0)
auto tod2 = TimeOfDay(7, 12, 0);
tod2 .roll!"hours"(-1);
writeln(tod2); // TimeOfDay(6, 12, 0)
auto tod3 = TimeOfDay(23, 59, 0);
tod3 .roll!"minutes"(1);
writeln(tod3); // TimeOfDay(23, 0, 0)
auto tod4 = TimeOfDay(0, 0, 0);
tod4 .roll!"minutes"(-1);
writeln(tod4); // TimeOfDay(0, 59, 0)
auto tod5 = TimeOfDay(23, 59, 59);
tod5 .roll!"seconds"(1);
writeln(tod5); // TimeOfDay(23, 59, 0)
auto tod6 = TimeOfDay(0, 0, 0);
tod6 .roll!"seconds"(-1);
writeln(tod6); // TimeOfDay(0, 0, 59)
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.