time_origin
Stable function · Other
Tier: stable · Kind: function · Topic: Other
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
time_origin | not exported | time_origin | time_origin | not exported |
Julia
time_origin(file::EsmFile)
time_origin(domain::Union{Nothing, AbstractString, Real, Domain, AbstractDict, AbstractVector})
time_origin(file::EsmFile) -> Float64
time_origin(domain) -> Float64
The time origin in seconds from the POSIX epoch: the instant
domain.temporal.reference_time — else domain.temporal.start, else the epoch
itself — names, as W₀ + f₀, whole seconds in integers and the fraction in
binary64. This is the origin a solver.time_span timestamp is counted from
(esm-spec §2.2.7), exposed so a caller does the same arithmetic for a timestamp
of its own with timestamp_to_seconds
.
The origin comes from a loaded or in-memory document, or from its domain
alone: a typed Domain, the raw JSON domain object of a document
that has not been loaded (any AbstractDict, String- or Symbol-keyed, a
JSON3.Object included), or nothing for a document without one. The raw form
is read as the load-time check reads it, so a present key selects its field,
null included, and a temporal that is not an object has no origin field.
Raises time_origin_invalid, naming /domain/temporal/..., when the origin
field that applies is present but is not an RFC 3339 date-time naming a
calendar day, and naming /domain when a raw domain is not an object (a
string, an array, a number or a boolean).
TypeScript
TypeScript does not export this function.
Python
time_origin(source: EsmFile | Domain | dict[str, Any] | None) -> float
The time origin in binary64 seconds from the POSIX epoch.
The instant domain.temporal.reference_time – else
domain.temporal.start, else the epoch itself – names, as W0 + f0:
whole seconds in integers and the fraction in binary64. This is the origin a
solver.time_span timestamp counts from (esm-spec §2.2.7), exposed so a
caller does the same arithmetic for a timestamp of its own with
timestamp_to_seconds
.
source is a document (EsmFile
) or its
domain alone: a typed Domain
, the raw JSON
domain dict of a document that has not been loaded, or None for a
document without one. The raw form is read as the load-time check reads it:
a present key selects its field, null included, and a temporal that
is not an object has no origin field.
Raises time_origin_invalid naming /domain/temporal/... when the
origin field that applies is present but is not an RFC 3339 date-time naming
a calendar day, and naming /domain when a raw domain is not an object
(a string, a list, a number or a boolean); TypeError for a
source of any other type.
Rust
pub fn time_origin<S: TimeOriginSource + ?Sized>(source: &S) -> Result<f64, DiagnosticError>
The time origin in seconds from the POSIX epoch (esm-spec §2.2.7):
domain.temporal.reference_time, else domain.temporal.start, else the
epoch itself, as W0 + f0 – whole seconds converted, the fraction added in
binary64.
This is the origin a solver.time_span timestamp counts from: the W0/f0
half of what resolve_time_span
does, exposed so a caller can convert a
timestamp of its own with timestamp_to_seconds
. source is a document
or its domain, typed or raw JSON (TimeOriginSource
):
time_origin(&file), time_origin(&domain), time_origin(&doc["domain"]).
A field that is present but is not an RFC 3339 date-time naming a calendar
day fails with time_origin_invalid, naming its pointer; so does a raw
domain that is not an object, naming /domain.
Go
Go does not export this function.