Public Documentation
Datetime
Tempo.Date
— TypeDate
A type to represent a calendar date by storing the year, month and day.
Date(year::Int, month::Int, day::Int)
Construct a Date
object given the year
, month
and day
.
Date(offset::Integer)
Create a Date
object given an integer number of days since 2000-01-01
.
Date(year::Integer, dayinyear::Integer)
Create a Date
object given the year
and the day of the year dayinyear
.
Examples
julia> Date(2020, 1)
2020-01-01
julia> Date(2020, 300)
2020-10-26
Date(dt::DateTime)
Extract the Date
object from a DateTime
structure.
See also
Tempo.Time
— TypeTime{T}
A type representing the time of the day storing the hour, minute, seconds and fraction of seconds.
Time(hour::Int, minute::Int, second::Int, fraction::T) where {T <: Number}
Create a Time
object of type T
.
Time(hour::Int, minute::Int, second::Number)
Construct a Time
object given the hour
, minute
and seconds
. In this case, the seconds can either be an integer or a floating point number. The fraction of seconds will be computed under the hood.
Time(secondinday::Int, fraction::Number)
Time(secondinday::Number)
Create a Time
object given the seconds of the day secondinday
and/or the fraction of seconds.
Time(dt::DateTime)
Extract the Time
object from a DateTime
structure.
See also
Tempo.DateTime
— TypeDateTime{T}
A type wrapping a Date
and a Time
object.
DateTime(date::Date, time::Time{T})
Construct a DateTime
object of type T
from its Date
and Time
components.
DateTime(year::Int, month::Int, day::Int, hour::Int, min::Int, sec::Int, frac::Number)
Create a DateTime
object by parts.
DateTime(iso::AbstractString)
Create a DateTime
object from by parsing an ISO datetime string iso
, in the format YYYY-MM-DDThh:mm:ss.ffffffff
. The DateTime parts not provided in the string will be assigned default values.
Examples
julia> DateTime("2023-05-18T20:14:55.02")
2023-05-18T20:14:55.020
julia> Tempo.DateTime("2022-05-12")
2022-05-12T00:00:00.00
DateTime(seconds::Number)
Create a DateTime
object given the number of seconds elapsed since J2000
.
DateTime(d::Date, sec::Number)
Create a DateTime
object given a Date
and the number of seconds since midnight.
Examples
julia> d = Date(2023, 5, 18)
2023-05-18
julia> DateTime(d, 0)
2023-05-18T12:00:00.000
julia> DateTime(d, 1)
2023-05-18T12:00:01.000
See also
Tempo.year
— Functionyear(d::Date)
Get year associated to a Date
.
year(d::DateTime)
Get year associated to a DateTime
type.
Tempo.month
— Functionmonth(d::Date)
Get month associated to a Date
.
month(d::DateTime)
Get month associated to a DateTime
type.
Tempo.day
— Functionday(d::Date)
Get day associated to a Date
.
day(d::DateTime)
Get day associated to a DateTime
type.
Tempo.hour
— Functionhour(t::Time)
Get the current hour.
hour(d::DateTime)
Get hour associated to a DateTime
type.
Tempo.minute
— Functionminute(t::Time)
Get the current minute.
minute(d::DateTime)
Get minute associated to a DateTime
type.
Tempo.second
— Functionsecond(::Type{<:AbstractFloat}, t::Time)
second(::Type{<:Integer}, t::Time)
second(t::Time)
Get the current second.
second(::Type{<:AbstractFloat}, t::Time)
second(d::DateTime)
Get the seconds associated to a DateTime
type. If a floating-point type is given as first argument, the returned value will also account for the fraction of seconds.
Tempo.find_dayinyear
— Functionfind_dayinyear(month::Integer, day::Integer, isleap::Bool)
Find the day of the year given the month, the day of the month and whether the year is leap or not.
find_dayinyear(d::Date)
Find the day in the year.
Epochs
Duration
Tempo.Duration
— TypeDuration{T} <: Number
A Duration
represents a period of time, split into an integer number of seconds and a fractional part for increased precision.
Fields
seconds
: The integer number of seconds.fraction
: The fractional part of the duration, whereT
is a subtype ofNumber
.
Duration(seconds::Number)
Create a Duration
object from a number of seconds. The type of the fractional part will be inferred from the type of the input argument.
Duration{T}(seconds::Number)
Create a Duration
object from a number of seconds with the fractional part of type T
.
Examples
julia> d = Duration(10.783)
Duration{Float64}(10, 0.7829999999999995)
julia> value(d)
10.783
julia> d = Duration{BigFloat64}(10.3)
Duration{BigFloat}(10, 0.300000000000000710542735760100185871124267578125)
Types
Tempo.Epoch
— TypeEpoch{S, T}
A type to represent Epoch-like data. Epochs are internally represented as seconds + fraction of seconds since a reference epoch, which is considered to be 2000-01-01T12:00:00
, i.e. J2000
.
Epoch(sec::Number, scale::AbstractTimeScale)
Epoch(sec::Number, scale::Type{<:AbstractTimeScale})
Epoch{S}(seconds::Number) where {S <: AbstractTimeScale}
Create an Epoch
object from the number of seconds since J2000
with the timescale S
.
Epoch(dt::DateTime, scale::AbstractTimeScale)
Epoch(dt::DateTime, scale::Type{<:AbstractTimeScale})
Create an Epoch
object from a DateTime
structure with timescale scale
.
Epoch(str::AbstractString, scale::AbstractTimeScale)
Epoch(str::AbstractString)
Create an Epoch
object from an ISO-formatted string. The timescale can either be specified as a second argument or written at the end of the string.
This constructor requires that the str
is in the format:
- ISO –
yyyy-mm-ddTHH:MM:SS.ffff
: assume J2000 as origin - J2000 –
DDDD.ffff
: parse Julian Date since J2000, in days - JD –
JD DDDDDDDDD.ffffff
: parse Julian Date, in days - MJD –
MJD DDDDDDDDD.ffffff
: parse a Modified Julian Date, in days
A TimeScale
can be added at the end of the string, separated by a whitespace. If it is not declared, TDB
will be used as a default timescale.
Examples
julia> Epoch("2050-01-01T12:35:15.0000 TT")
2050-01-01T12:35:14.9999 TT
julia> Epoch("2050-01-01T12:35:15.0000")
2050-01-01T12:35:14.9999 TDB
julia> Epoch("JD 2400000.5")
1858-11-17T00:00:00.0000 TDB
julia> Epoch("MJD 51544.5")
2000-01-01T12:00:00.0000 TDB
julia> Epoch("12.0")
2000-01-13T12:00:00.0000 TDB
julia> Epoch("12.0 TT")
2000-01-13T12:00:00.0000 TT
Tempo.timescale
— Functiontimescale(e::Epoch)
Epoch timescale.
Tempo.value
— Functionvalue(d::Duration)
Return the duration d
, in seconds.
value(e::Epoch)
Full Epoch
value.
Origins
Tempo.JD
— ConstantJD
The singleton instance of the JulianDate
epoch origin.
With this origin, Epoch reference is -4712-01-01T12:00
.
Tempo.J2000
— ConstantJ2000
The singleton instance of the JulianDate2000
epoch origin.
With this origin, Epoch reference is 2000-01-01T12:00
.
Tempo.MJD
— ConstantMJD
The singleton instance of the ModifiedJulianDate
epoch origin.
With this origin, Epoch reference is 1858-11-17T00:00
.
Tempo.MJD2000
— ConstantMJD2000
The singleton instance of the ModifiedJulianDate2000
epoch origin.
With this origin, Epoch reference is 2000-01-01T00:00
.
Conversions
Tempo.j2000
— Functionj2000(jd)
j2000(jd1, jd2)
Convert Julian Date in days since J2000
j2000(e::Epoch)
Convert Epoch
in Julian Date days since J2000
.
Tempo.j2000s
— Functionj2000s(jd)
j2000s(jd1, jd2)
Convert Julian Date (in days) in seconds past J2000
j2000s(e::Epoch)
Convert Epoch
in Julian Date seconds since J2000
.
Tempo.j2000c
— Functionj2000c(jd)
j2000c(jd1, jd2)
Convert Julian Date (in days) to Julian Centuries
j2000c(e::Epoch)
Convert Epoch
in Julian Date centuries since J2000
.
Timescales
Time System
Tempo.@timescale
— Macro@timescale(name, id, type)
Create a new timescale instance to alias the given id
. This macro creates an AbstractTimeScale
subtype and its singleton instance called name
. Its type
is obtained by appending TimeScale
to name
if it was not provided.
Examples
julia> @timescale NTS 100 NewTimeScale
julia> typeof(NTS)
NewTimeScale
julia> timescale_alias(NTS)
100
julia> @timescale TBH 200
julia> typeof(TBH)
TBHTimeScale
julia> timescale_alias(TBH)
200
See also
See also timescale_alias
and add_timescale!
.
Tempo.timescale_alias
— Functiontimescale_alias(scale::AbstractTimeScale)
Return the ID associated to scale
.
Tempo.timescale_name
— Functiontimescale_name(scale::AbstractTimeScale)
Return the name of scale
.
Tempo.timescale_id
— Functiontimescale_id(scale::AbstractTimeScale)
Return the ID of scale
.
Tempo.TimeSystem
— TypeTimeSystem{T}
A TimeSystem
object manages a collection of default and user-defined TimeScaleNode
objects, enabling efficient time transformations between them. It leverages a MappedDiGraph
to keep track of the relationships between the timescales.
TimeSystem{T}()
Create a empty TimeSystem
object with datatype T
.
Examples
julia> ts = TimeSystem{Float64}();
julia> @timescale TSA 100 TimeScaleA
julia> @timescale TSB 200 TimeScaleB
julia> add_timescale!(ts, TSA)
julia> offset_tsa2tsb(seconds) = 1.0
julia> offset_tsb2tsa(seconds) = -1.0
julia> add_timescale!(ts, TSB, offset_tsa2tsb; parent=TSA, ftp=offset_tsb2tsa)
See also
See also @timescale
and add_timescale!
.
Tempo.add_timescale!
— Functionadd_timescale!(s::TimeSystem, ts::TimeScaleNode)
Register a new node in the TimeSystem
.
This is a low-level function and should not be called by the user.
add_timescale!(system::TimeSystem, scale::AbstractTimeScale, ffp::Function; ftp, parent)
Add scale
as a timescale to system
. A custom function ffp
providing the time offset, in seconds, between the parent
scale and the current scale must be provided by the user.
The parent
and ffp
arguments are unneeded only for the root timescale. If the user wishes to add a scale to a non-empty timesystem, this argument becomes mandatory.
The input functions must accept only the seconds in the parent scale as argument and must return a single numerical output. An optional function ftp
, with a similar interface, returning the offset from the current to the parent scale may also be provided.
If ftp
is not provided, the reverse timescale transformation will not be possible.
Examples
julia> SYSTEM = TimeSystem{Float64}();
julia> @timescale RTS 102 RootTimeScale
julia> @timescale CTS 103 ChildTimeScale
julia> root_to_child(x::Number) = 13.3;
julia> child_to_root(x::Number) = -13.3;
julia> add_timescale!(SYSTEM, RTS)
julia> add_timescale!(SYSTEM, CTS, root_to_child; parent=RTS, ftp=child_to_root)
See also
See also @timescale
and TimeSystem
.
Tempo.TIMESCALES
— ConstantTIMESCALES
Default time scales graph, containing at least: ("TT", "TAI", "UTC", "TCG", "TCB", "TDB", "UT1", "TDBH", "GPS")
It can be easily extended using the @timescale
to create new TimeScaleNode
aliases and add_timescale!
method to define its relation with the other nodes in the graph.
Example
# Define a new timescale type alias
@timescale NTS 100 NewTimeScale
# Define offset to and from another timescale in the graph
offset_ffp(seconds) = 1.0
offset_ftp(seconds) = -1.0
# Connect to the graph, with the parent node (TDB in this example)
add_timescale!(TIMESCALES, NTS, offset_ffp, parent=TDB, ftp=offset_ftp)
See also
See also @timescale
and add_timescale!
.
Default Timescales
Tempo.GPS
— ConstantGPS
The singleton instance of the GlobalPositioningSystemTime
type representing the Global Positioning System Time (GPS) time scale.
Tempo.TAI
— ConstantTAI
The singleton instance of the InternationalAtomicTime
type representing the International Atomic Time (TAI) time scale.
Tempo.TCB
— ConstantTCB
The singleton instance of the BarycentricCoordinateTime
type representing the Barycentric Coordinate Time (TCB) time scale.
Tempo.TCG
— ConstantTCG
The singleton instance of the GeocentricCoordinateTime
type representing the Geocentric Coordinate Time (TCG) time scale.
Tempo.TDB
— ConstantTDB
The singleton instance of the BarycentricDynamicalTime
type representing the Barycentric Dynamical Time (TDB) time scale.
Tempo.TDBH
— ConstantTDBH
The singleton instance of the HighPrecisionBarycentricDynamicalTime
type representing the High Precision Barycentric Dynamical Time (TDBH) time scale.
Tempo.TT
— ConstantTT
The singleton instance of the TerrestrialTime
type representing the Terrestrial Time (TT) time scale.
Tempo.UT1
— ConstantUT1
The singleton instance of the UniversalTime
type representing the Universal Time (UT1) time scale.
Tempo.UTC
— ConstantUTC
The singleton instance of the CoordinatedUniversalTime
type representing the Coordinated Universal Time (UTC) time scale.
Constants
Tempo.DJ2000
— ConstantDJ2000
Reference epoch J2000
, Julian Date (2451545.0
). It is 12:00 01-01-2000
.
Tempo.DMJD
— ConstantDMJD
Reference epoch J2000
, Modified Julian Date (51544.5
).
Tempo.DJM0
— ConstantDJM0
Julian Date of Modified Julian Date zero point (2400000.5
). It is 00:00 17-11-1858
.