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
Adds the requested minutes to a date returning a datetime in the UTC time zone
Arguments
minutes
is a float number of minutes since midnightdate
is any date in the Gregorian calendar
Returns
- a datetime in the UTC time zone
Returns the datetime for a given Julian day
Arguments
julian_day
is any astronomical Julian day such as returned fromAstro.Time.julian_day_from_date/1
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]}
Returns the number of seconds since 0001-01-01
in the Gregorian calendar.
Arguments
datetime
is anyDateTime.t
since0001-01-01
in theCalendar.ISO
calendar
Returns
- An integer number of seconds since
0001-01-01
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}
Returns the Julian centuries for a given Julian day
Arguments
julian_day
is any astronomical Julian day such as returned fromAstro.Time.julian_day_from_date/1
Returns
- the astronomical Julian century as a
float
Returns the astronomical Julian day for a given date
Arguments
date
is anyCalendar.date
Returns
- the astronomical Julian day as a
float
Example
iex> Astro.Time.julian_day_from_date ~D[2019-12-05] 2458822.5
Returns the Julian day for a given Julian century
Arguments
julian_century
is any astronomical Julian century such as returned fromAstro.Time.julian_centuries_from_julian_day/1
Returns
- the astronomical Julian day as a
float
Returns the modified Julian day for a date
Arguments
date
is anyCalendar.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.
Converts a float number of hours since midnight to
a DateTime.t()
Arguments
time_of_day
is a float number of hours since midnightdate
is anyCalendar.date()
Returns
A DateTime.t()
combining the date
and time_of_day
in the UTC timezone.
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}
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).