timestamp_to_seconds
Stable function · Other
Tier: stable · Kind: function · Topic: Other
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
timestamp_to_seconds | not exported | timestamp_to_seconds | timestamp_to_seconds | not exported |
Julia
timestamp_to_seconds(file::EsmFile, timestamp)
timestamp_to_seconds(domain::Union{Nothing, AbstractString, Real, Domain, AbstractDict, AbstractVector}, timestamp)
timestamp_to_seconds(file::EsmFile, timestamp) -> Float64
timestamp_to_seconds(domain, timestamp) -> Float64
timestamp, an RFC 3339 UTC timestamp (YYYY-MM-DDThh:mm:ss[.f]Z — the
solver.time_span bound form), as seconds from the time origin of file or of
domain (typed, raw JSON or nothing, as for time_origin
):
(W − W₀) + (f − f₀), the whole-second difference in integers and then the
fractions in binary64, exactly as resolve_time_span
converts a
time_span timestamp (esm-spec §2.2.7).
Each cause has its own code, checked in this order, so the first that applies is the one raised:
timestamp_malformed—timestampis not a string, or not of that form;timestamp_no_calendar_day— it is of that form but its day is not in its month (2019-02-30,02-29outside a leap year);time_origin_invalid— the origin field that applies cannot be read, or a rawdomainis not an object.
The timestamp is checked before the origin, so a bad timestamp is reported as such even when the origin is also unreadable.
TypeScript
TypeScript does not export this function.
Python
timestamp_to_seconds(source: EsmFile | Domain | dict[str, Any] | None, timestamp: str) -> float
timestamp as seconds from source’s time origin (esm-spec §2.2.7).
timestamp is an RFC 3339 UTC timestamp (YYYY-MM-DDThh:mm:ss[.f]Z,
the solver.time_span bound form). The result is (W - W0) + (f - f0):
the whole-second difference in integers, then the fractions added in
binary64 – exactly what resolve_time_span
does to a time_span
timestamp. source and the origin are as for time_origin
.
Each cause has its own code, checked in this order, so the first that applies is the one raised:
timestamp_malformed–timestampis not a string, or not of that form;timestamp_no_calendar_day– it is of that form but its day is not in its month (2019-02-30,02-29outside a leap year);time_origin_invalid– the origin field that applies cannot be read, or a rawdomainis not an object.
A source of a type time_origin
does not take is a
TypeError, raised before the timestamp is looked at.
Rust
pub fn timestamp_to_seconds<S: TimeOriginSource + ?Sized>(source: &S, timestamp: &str) -> Result<f64, DiagnosticError>
timestamp as seconds from source’s time origin (esm-spec §2.2.7).
timestamp is an RFC 3339 UTC timestamp (YYYY-MM-DDThh:mm:ss[.f]Z, the
solver.time_span bound form). The result is (W - W0) + (f - f0): the
whole-second difference in integers, then the fractions added in binary64,
exactly as resolve_time_span
converts a time_span timestamp. source
and the origin are as for time_origin
.
Each cause has its own code, checked in this order, so the first that applies is the one returned:
timestamp_malformed–timestampis not of that form;timestamp_no_calendar_day– it is, but its day is not in its month (2019-02-30,02-29outside a leap year);time_origin_invalid– the origin field that applies cannot be read, or a rawdomainis not an object.
Go
Go does not export this function.