Version: v0.7.0

timestamp_to_seconds

Stable function · Other

Tier: stable · Kind: function · Topic: Other

JuliaTypeScriptPythonRustGo
timestamp_to_secondsnot exportedtimestamp_to_secondstimestamp_to_secondsnot 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:

  1. timestamp_malformed — timestamp is not a string, or not of that form;
  2. timestamp_no_calendar_day — it is of that form but its day is not in its month (2019-02-30, 02-29 outside a leap year);
  3. time_origin_invalid — the origin field that applies cannot be read, or a raw domain is 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.

Source

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:

  1. timestamp_malformed – timestamp is not a string, or not of that form;
  2. timestamp_no_calendar_day – it is of that form but its day is not in its month (2019-02-30, 02-29 outside a leap year);
  3. time_origin_invalid – the origin field that applies cannot be read, or a raw domain is not an object.

A source of a type time_origin does not take is a TypeError, raised before the timestamp is looked at.

Source

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:

  1. timestamp_malformed – timestamp is not of that form;
  2. timestamp_no_calendar_day – it is, but its day is not in its month (2019-02-30, 02-29 outside a leap year);
  3. time_origin_invalid – the origin field that applies cannot be read, or a raw domain is not an object.

Source · Rust docs

Go

Go does not export this function.