Public Documentation

Datetime

Tempo.DateType
Date

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

See also Time and DateTime.

source
Tempo.TimeType
Time{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

See also Date and DateTime.

source
Tempo.DateTimeType
DateTime{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

See also Date, Time and Epoch.

source
Tempo.secondFunction
second(::Type{<:AbstractFloat}, t::Time)
second(::Type{<:Integer}, t::Time)
second(t::Time)

Get the current second.

source
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.

source
Tempo.find_dayinyearFunction
find_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.

source
find_dayinyear(d::Date)

Find the day in the year.

source

Epochs

Duration

Tempo.DurationType
Duration{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, where T is a subtype of Number.

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)
source

Types

Tempo.EpochType
Epoch{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:

  • ISOyyyy-mm-ddTHH:MM:SS.ffff : assume J2000 as origin
  • J2000DDDD.ffff : parse Julian Date since J2000, in days
  • JDJD DDDDDDDDD.ffffff : parse Julian Date, in days
  • MJDMJD 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
source
Tempo.valueFunction
value(d::Duration)

Return the duration d, in seconds.

source
value(e::Epoch)

Full Epoch value.

source

Origins

Tempo.JDConstant
JD

The singleton instance of the JulianDate epoch origin.

With this origin, Epoch reference is -4712-01-01T12:00.

source

Conversions

Tempo.j2000Function
j2000(jd)
j2000(jd1, jd2)

Convert Julian Date in days since J2000

source
j2000(d::Date)

Convert Gregorian calendar date Date to a Julian Date since J2000, in days.

source
j2000(dt::DateTime)

Convert a DateTime dt in Julian days since J2000.

source
j2000(e::Epoch)

Convert Epoch in Julian Date days since J2000.

source
Tempo.j2000sFunction
j2000s(jd)
j2000s(jd1, jd2)

Convert Julian Date (in days) in seconds past J2000

source
j2000s(dt::DateTime)

Convert a DateTime dt to seconds since J2000.

source
j2000s(e::Epoch)

Convert Epoch in Julian Date seconds since J2000.

source
Tempo.j2000cFunction
j2000c(jd)
j2000c(jd1, jd2)

Convert Julian Date (in days) to Julian Centuries

source
j2000c(dt::DateTime)

Convert a DateTime dt in a Julian Date since J2000, in centuries.

source
j2000c(e::Epoch)

Convert Epoch in Julian Date centuries since J2000.

source

Timescales

Time System

Tempo.@timescaleMacro
@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!.

source
Tempo.TimeSystemType
TimeSystem{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!.

source
Tempo.add_timescale!Function
add_timescale!(s::TimeSystem, ts::TimeScaleNode)

Register a new node in the TimeSystem.

Warning

This is a low-level function and should not be called by the user.

source
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.

Note

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.

source
Tempo.TIMESCALESConstant
TIMESCALES

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!.

source

Default Timescales

Constants

Tempo.DJM0Constant
DJM0

Julian Date of Modified Julian Date zero point (2400000.5). It is 00:00 17-11-1858.

source