View Source SpaceDust.Time.UTC (Space Dust v0.3.0)

Coordinated Universal Time (UTC).

UTC is the primary civil time standard. It is kept within 0.9 seconds of UT1 (astronomical time based on Earth's rotation) by the insertion of leap seconds.

Internally stores time as fractional seconds since Unix epoch (1970-01-01 00:00:00 UTC).

Summary

Functions

Add seconds to UTC time.

Difference between two UTC times in seconds.

Create from year, month, day, hour, minute, second.

Create a UTC time from an Elixir DateTime.

Create a UTC time from a sigil-style DateTime.

Create from Julian Date.

Create from Modified Julian Date.

Create from Nx tensor.

Create a UTC time from Unix seconds.

Convert to an Elixir DateTime.

Convert to Julian Date.

Convert to Modified Julian Date.

Convert to Nx tensor (unix seconds).

Get the Unix seconds value.

Types

t()

@type t() :: %SpaceDust.Time.UTC{unix_seconds: float()}

Functions

add(utc, seconds)

@spec add(t(), number()) :: t()

Add seconds to UTC time.

diff(utc1, utc2)

@spec diff(t(), t()) :: float()

Difference between two UTC times in seconds.

from_components(year, month, day, hour, minute, second)

@spec from_components(integer(), integer(), integer(), integer(), integer(), number()) ::
  t()

Create from year, month, day, hour, minute, second.

from_datetime(dt)

@spec from_datetime(DateTime.t()) :: t()

Create a UTC time from an Elixir DateTime.

from_iso8601!(iso_string)

@spec from_iso8601!(String.t()) :: t()

Create a UTC time from a sigil-style DateTime.

Example

iex> SpaceDust.Time.UTC.from_iso8601!("2024-01-01T12:00:00Z")

from_jd(jd)

@spec from_jd(float()) :: t()

Create from Julian Date.

from_mjd(mjd)

@spec from_mjd(float()) :: t()

Create from Modified Julian Date.

from_tensor(tensor)

@spec from_tensor(Nx.Tensor.t()) :: t()

Create from Nx tensor.

new(unix_seconds)

@spec new(float()) :: t()

Create a UTC time from Unix seconds.

to_datetime(utc)

@spec to_datetime(t()) :: DateTime.t()

Convert to an Elixir DateTime.

to_jd(utc)

@spec to_jd(t()) :: float()

Convert to Julian Date.

to_mjd(utc)

@spec to_mjd(t()) :: float()

Convert to Modified Julian Date.

to_tensor(utc)

@spec to_tensor(t()) :: Nx.Tensor.t()

Convert to Nx tensor (unix seconds).

to_unix(utc)

@spec to_unix(t()) :: float()

Get the Unix seconds value.