Duration

struct Duration

A signed time span stored as a 64-bit nanosecond count.

Unit constructors and arithmetic use the normal trapping integer operators; large conversions can therefore perform 'panic on overflow. as_* conversions truncate toward zero. Duration has no calendar or clock identity.

Methods

static func nanoseconds(_ count: Int) -> Duration

Creates a duration from a nanosecond count.

View Source
pub static func nanoseconds(_ count: Int) -> Duration {
	Duration(nanos: count)
}

static func microseconds(_ count: Int) -> Duration

Creates a duration from a microsecond count.

View Source
pub static func microseconds(_ count: Int) -> Duration {
	Duration(nanos: count * 1000)
}

static func milliseconds(_ count: Int) -> Duration

Creates a duration from a millisecond count.

View Source
pub static func milliseconds(_ count: Int) -> Duration {
	Duration(nanos: count * 1000000)
}

static func seconds(_ count: Int) -> Duration

Creates a duration from a second count.

View Source
pub static func seconds(_ count: Int) -> Duration {
	Duration(nanos: count * 1000000000)
}

static func minutes(_ count: Int) -> Duration

Creates a duration from a minute count.

View Source
pub static func minutes(_ count: Int) -> Duration {
	Duration(nanos: count * 60000000000)
}

static func hours(_ count: Int) -> Duration

Creates a duration from an hour count.

View Source
pub static func hours(_ count: Int) -> Duration {
	Duration(nanos: count * 3600000000000)
}

static func days(_ count: Int) -> Duration

Creates a duration from a day count.

View Source
pub static func days(_ count: Int) -> Duration {
	Duration(nanos: count * 86400000000000)
}

static func weeks(_ count: Int) -> Duration

Creates a duration from a week count.

View Source
pub static func weeks(_ count: Int) -> Duration {
	Duration(nanos: count * 604800000000000)
}