Skip to content
FutureBlitz

    Install

    Import std.time.duration

    std.time.duration

    Duration: a span of time to the nanosecond, as an Int64 of them, from about 292 years before to 292 years after. An Int64's or a Double's Nanoseconds, Microseconds, Milliseconds, Seconds, Minutes, Hours, and Days make one, as 2.Seconds, 1.5.Minutes, and 500.Milliseconds do, a literal taking whichever has them; a Double's round to the nearest nanosecond, ties to even, and one longer than a Duration holds panics. Its operators add and subtract Durations, scale one by a number, and divide one by a number or another Duration. Wait and RealWait take one, and ToString and Parse write and read one as Go does, like "1h30m0s" and "1.5ms".

    std/time/duration.fb

    Types

    Duration struct

    Public Struct Duration Implements Comparable, Hashable, Printable, Defaultable

    A length of time, in nanoseconds, below 0 for one that goes back.

    std/time/duration.fb, line 21

    • Public Static Method Zero(): Duration static method #

      No time at all.

    • Public Static Method DefaultValue(): Duration static method #

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

    • Public Static Method MaxValue(): Duration static method #

      The longest Durations, about 292 years either way.

    • Public Static Method MinValue(): Duration static method #

      The shortest Duration, about 292 years back.

    • Public Static Method FromNanoseconds(count: Int64): Duration static method #

      The Duration of that many nanoseconds.

    • Public Property Nanoseconds: Int64 property #

      Its nanoseconds, all of them.

    • Public Property TotalMicroseconds: Double property #

      It in microseconds, with a fraction for what's left: 1500 nanoseconds is 1.5.

    • Public Property TotalMilliseconds: Double property #

      It in milliseconds, with a fraction for what's left.

    • Public Property TotalSeconds: Double property #

      It in seconds, with a fraction for what's left.

    • Public Property TotalMinutes: Double property #

      It in minutes, with a fraction for what's left.

    • Public Property TotalHours: Double property #

      It in hours, with a fraction for what's left.

    • Public Property TotalDays: Double property #

      It in days, of 24 hours, with a fraction for what's left.

    • Public Property IsZero: Bool property #

      Whether it's no time at all.

    • Public Property IsNegative: Bool property #

      Whether it goes back.

    • @PanicsAtCaller Public Method Abs(): Duration method #

      It without its sign. MinValue's has none that fits, so it panics.

    • Public Method Truncate(unit: Duration): Duration method #

      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.

    • Public Method Round(unit: Duration): Duration method #

      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.

    • Public Method ToString(): String method #

      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".

    • Public Static Method Parse(text: String): Duration? static method #

      The Duration the text is, 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.

    • Operator <(a: Duration, b: Duration): Bool operator #

      Whether a comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

    • @PanicsAtCaller Operator +(a: Duration, b: Duration): Duration operator #

      a plus b, which panics past the longest Durations, as an Int64's overflow does.

    • @PanicsAtCaller Operator -(a: Duration, b: Duration): Duration operator #

      a minus b, which panics past the longest Durations, as an Int64's overflow does.

    • @PanicsAtCaller Operator -(a: Duration): Duration operator #

      a negated, which panics past the longest Durations, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: Int8): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: Int16): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: Int32): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: Int64): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: UInt8): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: UInt16): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: UInt32): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Int8, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Int16, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Int32, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Int64, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: UInt8, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: UInt16, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: UInt32, b: Duration): Duration operator #

      a times b, exactly. One longer than a Duration holds panics, as an Int64's overflow does.

    • @PanicsAtCaller Operator *(a: Duration, b: Double): Duration operator #

      a times b, to the nearest nanosecond, ties to even. One longer than a Duration holds panics, and so does a b that isn't a number.

    • @PanicsAtCaller Operator *(a: Double, b: Duration): Duration operator #

      a times b, to the nearest nanosecond, ties to even. One longer than a Duration holds panics, and so does an a that isn't a number.

    • @PanicsAtCaller Operator /(a: Duration, b: Int8): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: Int16): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: Int32): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: Int64): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: UInt8): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: UInt16): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: UInt32): Duration operator #

      a divided by b, rounded toward 0. Dividing by 0 panics, as an Int's / does.

    • @PanicsAtCaller Operator /(a: Duration, b: Double): Duration operator #

      a divided by b, to the nearest nanosecond, ties to even. Dividing by 0 panics, and so does a b that isn't a number.

    • @PanicsAtCaller Operator /(a: Duration, b: Duration): Double operator #

      How many of b fit in a, with a fraction. Dividing by a b of 0 panics.

    • @PanicsAtCaller Operator %(a: Duration, b: Duration): Duration operator #

      What's left of a over b, with a's sign, as an Int's % has, which panics for a b of 0.

    Extends

    Int64 extend

    Extend Int64

    No doc comment.

    std/time/duration.fb, line 466

    • @PanicsAtCaller Public Property Nanoseconds: Duration property #

      This many nanoseconds, as a Duration, as 5.Nanoseconds is.

    • @PanicsAtCaller Public Property Microseconds: Duration property #

      This many microseconds, as a Duration, as 5.Microseconds is. Panics when it's longer than a Duration holds.

    • @PanicsAtCaller Public Property Milliseconds: Duration property #

      This many milliseconds, as a Duration, as 5.Milliseconds is. Panics when it's longer than a Duration holds.

    • @PanicsAtCaller Public Property Seconds: Duration property #

      This many seconds, as a Duration, as 5.Seconds is. Panics when it's longer than a Duration holds.

    • @PanicsAtCaller Public Property Minutes: Duration property #

      This many minutes, as a Duration, as 5.Minutes is. Panics when it's longer than a Duration holds.

    • @PanicsAtCaller Public Property Hours: Duration property #

      This many hours, as a Duration, as 5.Hours is. Panics when it's longer than a Duration holds.

    • @PanicsAtCaller Public Property Days: Duration property #

      This many days, of 24 hours, as a Duration, as 5.Days is. Panics when it's longer than a Duration holds.

    Float64 extend

    Extend Float64

    No doc comment.

    std/time/duration.fb, line 516

    • @PanicsAtCaller Public Property Nanoseconds: Duration property #

      This many nanoseconds, to the nearest, as a Duration. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Microseconds: Duration property #

      This many microseconds, to the nearest nanosecond, as a Duration, as 1.5.Microseconds is. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Milliseconds: Duration property #

      This many milliseconds, to the nearest nanosecond, as a Duration, as 1.5.Milliseconds is. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Seconds: Duration property #

      This many seconds, to the nearest nanosecond, as a Duration, as 1.5.Seconds is. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Minutes: Duration property #

      This many minutes, to the nearest nanosecond, as a Duration, as 1.5.Minutes is. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Hours: Duration property #

      This many hours, to the nearest nanosecond, as a Duration, as 1.5.Hours is. Panics for NaN, an infinity, or one longer than a Duration holds.

    • @PanicsAtCaller Public Property Days: Duration property #

      This many days, to the nearest nanosecond, as a Duration, as 1.5.Days is. Panics for NaN, an infinity, or one longer than a Duration holds.

    Report an issue with this page or with FutureBlitz on GitHub.