TimeOfDay

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

Constructors

this
this(int hour, int minute, int second)

Members

Functions

opBinary
TimeOfDay opBinary(Duration duration)

Gives the result of adding or subtracting a core.time.Duration from this TimeOfDay.

opBinary
Duration opBinary(TimeOfDay rhs)

Gives the difference between two TimeOfDays.

opCmp
int opCmp(TimeOfDay rhs)

Compares this TimeOfDay with the given TimeOfDay.

opOpAssign
TimeOfDay opOpAssign(Duration duration)

Gives the result of adding or subtracting a core.time.Duration from this TimeOfDay, as well as assigning the result to this TimeOfDay.

roll
TimeOfDay roll(long value)

Adds the given number of units to this TimeOfDay, mutating it. A negative number will subtract.

toISOExtString
string toISOExtString()
void toISOExtString(W writer)

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
string toISOString()
void toISOString(W writer)

Converts this TimeOfDay to a string with the format HHMMSS. If writer is set, the resulting string will be written directly to it.

toString
string toString()
void toString(W writer)

Converts this TimeOfDay to a string.

Imports

Duration (from core.time)
public import core.time : Duration;
Undocumented in source.

Properties

hour
ubyte hour [@property getter]

Hours past midnight.

hour
int hour [@property setter]

Hours past midnight.

max
TimeOfDay max [@property getter]

Returns one second short of midnight.

min
TimeOfDay min [@property getter]

Returns midnight.

minute
ubyte minute [@property getter]

Minutes past the hour.

minute
int minute [@property setter]

Minutes past the hour.

second
ubyte second [@property getter]

Seconds past the minute.

second
int second [@property setter]

Seconds past the minute.

Static functions

fromISOExtString
TimeOfDay fromISOExtString(S isoExtString)

Creates a TimeOfDay from a string with the format HH:MM:SS. Whitespace is stripped from the given string.

fromISOString
TimeOfDay fromISOString(S isoString)

Creates a TimeOfDay from a string with the format HHMMSS. Whitespace is stripped from the given string.

Examples

import core.time : minutes, seconds;

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

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

assert(t.toISOExtString() == "12:41:40");
assert(t.toISOString() == "124140");

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

Meta