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.

Struct std.datetime.date.TimeOfDay

Represents a time of day with hours, minutes, and seconds. It uses 24 hour time.

struct TimeOfDay ;

Constructors

NameDescription
this (hour, minute, second)

Properties

NameTypeDescription
hour[get] ubyteHours past midnight.
hour[set] intHours past midnight.
max[get] TimeOfDayReturns one second short of midnight.
min[get] TimeOfDayReturns midnight.
minute[get] ubyteMinutes past the hour.
minute[set] intMinutes past the hour.
second[get] ubyteSeconds past the minute.
second[set] intSeconds past the minute.

Methods

NameDescription
fromISOExtString (isoExtString) Creates a TimeOfDay from a string with the format HH:MM:SS. Whitespace is stripped from the given string.
fromISOString (isoString) Creates a TimeOfDay from a string with the format HHMMSS. Whitespace is stripped from the given string.
opBinary (duration) Gives the result of adding or subtracting a Duration from this TimeOfDay.
opBinary (rhs) Gives the difference between two TimeOfDays.
opCmp (rhs) Compares this TimeOfDay with the given TimeOfDay.
opOpAssign (duration) Gives the result of adding or subtracting a Duration from this TimeOfDay, as well as assigning the result to this TimeOfDay.
roll (value) Adds the given number of units to this TimeOfDay, mutating it. A negative number will subtract.
toISOExtString () Converts this TimeOfDay to a string with the format HH:MM:SS. If writer is set, the resulting string will be written directly to it.
toISOString () Converts this TimeOfDay to a string with the format HHMMSS. If writer is set, the resulting string will be written directly to it.
toString () Converts this TimeOfDay to a string.

Example

import core.time : minutes, seconds;

auto t = TimeOfDay(12, 30, 0);

t += 10.minutes + 100.seconds;
writeln(t); // TimeOfDay(12, 41, 40)

writeln(t.toISOExtString()); // "12:41:40"
writeln(t.toISOString()); // "124140"

writeln(TimeOfDay.fromISOExtString("15:00:00")); // TimeOfDay(15, 0, 0)
writeln(TimeOfDay.fromISOString("015000")); // TimeOfDay(1, 50, 0)

Authors

Jonathan M Davis

License

Boost License 1.0.