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
Name | Description |
---|---|
this
|
Properties
Name | Type | Description |
---|---|---|
hour [get]
|
ubyte | Hours past midnight. |
hour [set]
|
int | Hours past midnight. |
max [get]
|
TimeOfDay | Returns one second short of midnight. |
min [get]
|
TimeOfDay | Returns midnight. |
minute [get]
|
ubyte | Minutes past the hour. |
minute [set]
|
int | Minutes past the hour. |
second [get]
|
ubyte | Seconds past the minute. |
second [set]
|
int | Seconds past the minute. |
Methods
Name | Description |
---|---|
fromISOExtString
|
Creates a TimeOfDay from a string with the format HH:MM:SS.
Whitespace is stripped from the given string.
|
fromISOString
|
Creates a TimeOfDay from a string with the format HHMMSS.
Whitespace is stripped from the given string.
|
opBinary
|
Gives the result of adding or subtracting a Duration
from this TimeOfDay .
|
opBinary
|
Gives the difference between two TimeOfDay s.
|
opCmp
|
Compares this TimeOfDay with the given TimeOfDay .
|
opOpAssign
|
Gives the result of adding or subtracting a Duration
from this TimeOfDay , as well as assigning the result to this
TimeOfDay .
|
roll
|
Adds the given number of units to this TimeOfDay . 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
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.