Astro v0.4.0 Astro.Time View Source

Calculations converting between geometry and time

All public functions use degrees as their input parameters

Time is a fraction of a day after UTC

Link to this section Summary

Functions

Adds the requested minutes to a date returning a datetime in the UTC time zone

Returns the datetime for a given Julian day

Returns the number of seconds since 0001-01-01 in the Gregorian calendar.

Converts a float number of hours since midnight into {hours, minutes, seconds}.

Returns the Julian centuries for a given Julian day

Returns the astronomical Julian day for a given date

Returns the Julian day for a given Julian century

Returns the modified Julian day for a date

Converts a float number of hours since midnight to a DateTime.t()

Converts a number of seconds since midnight into {hours, minutes, seconds}.

Converts a terrestrial datetime to a UTC datetime

Link to this section Functions

See Astro.Time.julian_day_from_date/1.

Link to this function

datetime_from_date_and_minutes(minutes, date)

View Source

Adds the requested minutes to a date returning a datetime in the UTC time zone

Arguments

  • minutes is a float number of minutes since midnight

  • date is any date in the Gregorian calendar

Returns

  • a datetime in the UTC time zone
Link to this function

datetime_from_julian_days(julian_days)

View Source

Returns the datetime for a given Julian day

Arguments

Returns

  • a DateTime.t in the UTC time zone

Example

iex> Astro.Time.datetime_from_julian_days 2458822.5
{:ok, ~U[2019-12-05 00:00:00Z]}
Link to this function

datetime_to_gregorian_seconds(datetime)

View Source

Returns the number of seconds since 0001-01-01 in the Gregorian calendar.

Arguments

  • datetime is any DateTime.t since 0001-01-01in the Calendar.ISO calendar

Returns

  • An integer number of seconds since 0001-01-01
Link to this function

days_from_minutes(minutes)

View Source
Link to this function

hours_to_hms(time_of_day)

View Source

Converts a float number of hours since midnight into {hours, minutes, seconds}.

Arguments

  • time_of_day is a float number of hours since midnight

Returns

  • A {hour, minute, second} tuple.

Examples

iex> Astro.Time.hours_to_hms 0.0 {0, 0, 0} iex> Astro.Time.hours_to_hms 23.999 {23, 59, 56} iex> Astro.Time.hours_to_hms 15.456 {15, 27, 21}

Link to this function

julian_centuries_from_julian_day(julian_day)

View Source

Returns the Julian centuries for a given Julian day

Arguments

Returns

  • the astronomical Julian century as a float
Link to this function

julian_day_from_date(date)

View Source

Returns the astronomical Julian day for a given date

Arguments

  • date is any Calendar.date

Returns

  • the astronomical Julian day as a float

Example

iex> Astro.Time.julian_day_from_date ~D[2019-12-05] 2458822.5

Link to this function

julian_day_from_julian_centuries(julian_centuries)

View Source

Returns the Julian day for a given Julian century

Arguments

Returns

  • the astronomical Julian day as a float

Returns the modified Julian day for a date

Arguments

  • date is any Calendar.date

Returns

  • the modified Julian day as a float

Notes

A modified version of the Julian date denoted MJD is obtained by subtracting 2,400,000.5 days from the Julian date JD,

The MJD therefore gives the number of days since midnight on November 17, 1858. This date corresponds to 2400000.5 days after day 0 of the Julian calendar.

Link to this function

moment_to_datetime(time_of_day, map)

View Source

Converts a float number of hours since midnight to a DateTime.t()

Arguments

  • time_of_day is a float number of hours since midnight

  • date is any Calendar.date()

Returns

A DateTime.t() combining the date and time_of_day in the UTC timezone.

Link to this function

seconds_to_hms(time_of_day)

View Source

Converts a number of seconds since midnight into {hours, minutes, seconds}.

Arguments

  • time_of_day is a number of seconds

Returns

  • A {hour, minute, second} tuple.

Examples

iex> Astro.Time.seconds_to_hms 0.0 {0, 0, 0} iex> Astro.Time.seconds_to_hms 3214 {0, 53, 34} iex> Astro.Time.seconds_to_hms 10_000 {2, 46, 39}

Link to this function

utc_datetime_from_terrestrial_datetime(datetime)

View Source

Converts a terrestrial datetime to a UTC datetime

Arguments

  • datetime is any UTC datetime which is considered to be a Terrestrial Time.

Returns

  • A UTC datetime adjusted for the difference between Terrestrial Time and UTC time

Notes

Terrestrial Time (TT) was introduced by the IAU in 1979 as the coordinate time scale for an observer on the surface of Earth. It takes into account relativistic effects and is based on International Atomic Time (TAI), which is a high-precision standard using several hundred atomic clocks worldwide. As such, TD is the atomic time equivalent to its predecessor Ephemeris Time (ET) and is used in the theories of motion for bodies in the solar system.

To ensure continuity with ET, TD was defined to match ET for the date 1977 Jan 01. In 1991, the IAU refined the definition of TT to make it more precise. It was also renamed Terrestrial Time (TT) from the earlier Terrestrial Dynamical Time (TDT).