Import std.time.duration
Duration
struct
Public Struct Duration Implements Comparable, Hashable, Printable, Defaultable
A length of time, in nanoseconds, below 0 for one that goes back.
Examples
Local trip = 90.Minutes
Expect(trip.TotalHours == 1.5)
Expect("{trip}" == "1h30m0s")
Expect(Duration.Parse("1h30m") == trip)
Expect(2.5.Seconds == 2500.Milliseconds)
Expect((trip - 2.Hours).IsNegative)-
No time at all.
-
No time at all, 0s.
-
The longest Duration, about 292 years ahead.
-
The shortest Duration, about 292 years back.
-
The Duration of that many nanoseconds.
-
Its nanoseconds, all of them.
-
It in microseconds, with a fraction for what's left: 1500 nanoseconds is 1.5.
-
It in milliseconds, with a fraction for what's left.
-
It in seconds, with a fraction for what's left.
-
It in minutes, with a fraction for what's left.
-
It in hours, with a fraction for what's left.
-
It in days, of 24 hours, with a fraction for what's left.
-
Whether it's no time at all.
-
Whether it goes back.
-
It without its sign. MinValue's has none that fits, so it panics.
-
It rounded toward 0 to a multiple of
unit, as 1h15m truncated to an hour is 1h. A unit that isn't above 0 leaves it as it is. -
It rounded to the nearest multiple of
unit, a half away from 0, as 1h30m rounded to an hour is 2h; past the longest Duration, it's the longest. A unit that isn't above 0 leaves it as it is. -
As Go writes it: hours, minutes, and seconds with a fraction, like "1h2m3.5s" and "2m0s", or below a second, one unit with a fraction, like "1.5ms", "250µs", and "80ns"; and "0s".
-
The Duration the
textis, as Go's ParseDuration reads it: a sign or none, then one or more numbers, each with a fraction or not and a unit, "ns", "us" (or "µs" or "μs"), "ms", "s", "m", or "h", as in "1h30m" and "-1.5s"; or "0". Other text, or a Duration longer than one holds, is Null. -
Whether
ais shorter thanb. -
aplusb, which panics past the longest Durations, as an Int64's overflow does. -
aminusb, which panics past the longest Durations, as an Int64's overflow does. -
anegated, which panics past the longest Durations, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, exactly. One longer than a Duration holds panics, as an Int64's overflow does. -
atimesb, to the nearest nanosecond, ties to even. One longer than a Duration holds panics, and so does abthat isn't a number. -
atimesb, to the nearest nanosecond, ties to even. One longer than a Duration holds panics, and so does anathat isn't a number. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, rounded toward 0. Dividing by 0 panics, as an Int's / does. -
adivided byb, to the nearest nanosecond, ties to even. Dividing by 0 panics, and so does abthat isn't a number. -
How many of
bfit ina, with a fraction. Dividing by abof 0 panics. -
What's left of
aoverb, witha's sign, as an Int's % has, which panics for abof 0.
Report an issue with this page or with FutureBlitz on GitHub.