Skip to content

Archmage.Duration

A length of time in nanoseconds, the type of a duration field.

Inherits: RefCounted

In the config files, a duration is null when it is zero, or an array that starts with a unit: [0, seconds], [1, milliseconds], [2, microseconds], [3, nanoseconds] or [4, seconds, nanoseconds]. For example, 1.5 seconds is [1, 1500].

var nanoseconds: int

The length in nanoseconds. It may be negative.

Archmage.Duration.new(ns: int = 0)
static func from_json(v: Variant, e: Archmage.ParseError = null) -> Archmage.Duration

Returns the duration in v, a parsed JSON value. For null and an empty array, returns a zero duration. For any other value that is not a valid duration, records the error in e (see Archmage.ParseError.report()) and returns a zero duration.

static func seconds_from_json(v: Variant, e: Archmage.ParseError = null) -> float

Returns the duration in v in seconds, such as 1.5. It accepts the same values as from_json() and records the same errors. Code generated with ARCHMAGE_GD_FLOAT_DURATION=true calls it for every duration.

func to_json() -> Variant

Returns the duration in the format of the config files.

func to_seconds() -> float

Returns the duration in seconds, such as 1.5. Use it for Godot APIs that take seconds, such as SceneTree.create_timer().

func to_milliseconds() -> int

Returns the duration in whole milliseconds, truncated toward zero.