Loading...
Searching...
No Matches
supernovas::Time Class Reference
Time of observation and astronomical timescales

Precise astronomical time specification, supporting all relevant astronomical timescales (UT1, UTC, TAI, GPS, TT, TDB, TCG, and TCB). More...

`#include <supernovas.h>`

Inheritance diagram for supernovas::Time:

## Public Member Functions

| Time (const novas_timespec *t)
| Instantiates an astrometric time instance with the specified SuperNOVAS C astrometric time specification data structure.
| Time (const std::string &timestamp, const EOP &eop=EOP::undefined(), enum novas_timescale timescale=NOVAS_UTC)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (const std::string &timestamp, int leap_seconds, double dUT1, enum novas_timescale timescale=NOVAS_UTC)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (const struct timespec *t, const EOP &eop=EOP::undefined())
| Instantiates an astrometric time instance with the specified time parameters.
| Time (const struct timespec *t, int leap_seconds, double dUT1)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (double jd, const EOP &eop=EOP::undefined(), enum novas_timescale timescale=NOVAS_TT)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (double jd, int leap_seconds, double dUT1, enum novas_timescale timescale=NOVAS_TT)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (long ijd, double fjd, const EOP &eop=EOP::undefined(), enum novas_timescale timescale=NOVAS_TT)
| Instantiates an astrometric time instance with the specified time parameters.
| Time (long ijd, double fjd, int leap_seconds, double dUT1, enum novas_timescale timescale=NOVAS_TT)
| Instantiates an astrometric time instance with the specified time parameters.
const novas_timespec * | _novas_timespec () const
| Returns the underlying C astrometric time specification data structure.
int | day_of_week (enum novas_timescale timescale=NOVAS_UTC) const
| Returns the day of week index (1..7) for this time instance.
Interval | dUT1 () const
| Returns the UT1 - UTC time difference for this time instance, as was provided during instantiation.
double | epoch () const
| Returns the Julian coordinate epoch year of this time instance.
bool | equals (const Time &time, const Interval &precision) const
| Checks if this time instance is the same as another time within the specified precision.
bool | equals (const Time &time, double seconds=Unit::us) const
| Checks if this time instance is the same as another time within the specified precision.
TimeAngle | era () const
| Returns the Earth Rotation Angle (ERA), which measures the angle between the Terrestrial Intermediate Origin (TIO) and the Celestial Intermediate Origin (CIO) in the IAU 2000 convention.
TimeAngle | gmst () const
| Returns the Greenwich Mean Sidereal Time (GMST) for this time instance.
TimeAngle | gst (enum novas_accuracy accuracy=NOVAS_FULL_ACCURACY) const
| Returns the Greenwich (Apparent) Sidereal Time (GST / GaST) for this time instance.
double | jd (enum novas_timescale timescale=NOVAS_TT) const
| Returns the precise Julian Date of this time instance, in the specific timescale of choice.
long | jd_day (enum novas_timescale timescale=NOVAS_TT) const
| Returns the integer Julian day of this time instance, in the specific timescale of choice.
double | jd_frac (enum novas_timescale timescale=NOVAS_TT) const
| Returns the factional Julian Day (MJD) of this time instance, in the specific timescale of choice.
int | leap_seconds () const
| Returns the leap seconds for this time instance, as was provided during instantiation.
TimeAngle | lst (const Site &site, enum novas_accuracy accuracy=NOVAS_FULL_ACCURACY) const
| Returns the Local (Apparent) Sidereal Time for this time instance.
double | mjd (enum novas_timescale timescale=NOVAS_TT) const
| Returns the precise Modified Julian Date (MJD) this time instance, in the specific timescale of choice.
long | mjd_day (enum novas_timescale timescale=NOVAS_TT) const
| Returns the integer Modified Julian Day (MJD) of this time instance, in the specific timescale of choice.
double | mjd_frac (enum novas_timescale timescale=NOVAS_TT) const
| Returns the integer Modified Julian Day (MJD) of this time instance, in the specific timescale of choice.
Angle | moon_phase () const
| Returns the phase of the Moon at this time instance.
Time | next_moon_phase (const Angle &phase) const
| Returns the next time, after this time instance, when the Moon will be in the specified phase.
Interval | offset_from (const Time &time, enum novas_timescale timescale=NOVAS_TT) const
| Returns the difference of this time from the specified other time, in the specified timescale.
bool | operator!= (const Time &time) const
| Checks if this time instance differs from another time by more than 1 μs.
Time | operator+ (const Interval &delta) const
| Returns an offset time in the forward direction.
Time | operator+ (double seconds) const
| Returns an offset time.
Interval | operator- (const CalendarDate &other) const
Time | operator- (const Interval &delta) const
| Returns an offset time.
Interval | operator- (const Time &other) const
| Returns the difference of this time from the specified other time, in regular Earth-based time measures (GPS, TAI, TT – and also UTC assuming no change in leap seconds).
Time | operator- (double seconds) const
| Returns an offset time in the backwards direction.
bool | operator< (const Time &other) const
| Checks if this time is prior to the specified other time, at the full precision of the representation.
bool | operator<= (const Time &other) const
| Checks if this time is the same as or before the specified other time, at 1 μs resolution.
bool | operator== (const Time &time) const
| Checks if this time instance is the same as another time within 1 μs.
bool | operator> (const Time &other) const
| Checks if this time is after to the specified other time, at the full precision of the representation.
bool | operator>= (const Time &other) const
| Checks if this time is the same as or after the specified other time, at 1 μs resolution.
Time | shifted (const Interval &offset, enum novas_timescale timescale=NOVAS_TT) const
| Returns an offset time.
Time | shifted (double seconds, enum novas_timescale timescale=NOVAS_TT) const
| Returns an offset time.
TimeAngle | time_of_day (enum novas_timescale timescale=NOVAS_TT) const
| Returns the time of (calendar) day of this time instance in the timescale of choice.
Interval | timescale_offset (enum novas_timescale timescale, enum novas_timescale ref_scale=NOVAS_TT) const
| Returns the time difference between two timescales at this specific time instance.
CalendarDate | to_calendar_date (const Calendar &calendar=Calendar::astronomical(), enum novas_timescale timescale=NOVAS_UTC) const
| Returns a calendar date, in the calendar of choice, and in the timescale of choice, for time instance.
CalendarDate | to_calendar_date (enum novas_timescale timescale) const
| Returns the astronomical calendar date instance for this astrometric time.
std::string | to_epoch_string (int decimals=2) const
| Returns the string representation of the Julian coordinate epoch corresponding to this timestamp.
std::string | to_iso_string () const
| Returns an ISO 8601 timestamp for this time instance.
std::string | to_string (enum novas_timescale timescale=NOVAS_UTC) const
| Returns a string representation (a timestamp) of this time instance.
time_t | unix_time (long *nanos=NULL) const
| Returns the precise UNIX time (UTC) corresponding to this time instance.
Public Member Functions inherited from supernovas::Validating
bool | is_valid () const
| Returns the previously set 'valid' state of the implementing instance.
| operator bool () const
| Objects that implement Validating can be used in conditionals directly, without explicitly calling is_valid().

## Static Public Member Functions

static const Time & | b1900 ()
| Returns the astrometric time for the B1900 epoch.
static const Time & | b1950 ()
| Returns the astrometric time for the B1950 epoch.
static Time | from_mjd (double mjd, const EOP &eop=EOP::undefined(), enum novas_timescale timescale=NOVAS_TT)
| Returns a new astrometric time instance for a given Modified Julian Date (MJD), specified in the timescale of choice.
static Time | from_mjd (double mjd, int leap_seconds, double dUT1, enum novas_timescale timescale=NOVAS_TT)
| Returns a new astrometric time instance for a given Modified Julian Date (MJD), specified in the timescale of choice.
static const Time & | hip ()
| Returns the astrometric time for the Hipparcos catalog epoch (which is J1991.25).
static const Time & | j2000 ()
| Returns the astrometric time for the J2000 epoch.
static Time | now (const EOP &eop=EOP::undefined())
| Resturns a new astrometric time instance for the current time.
static Time | now (int leap_seconds, double dUT1)
| Resturns a new astrometric time instance for the current time.
static const Time & | undefined ()
| Returns a reference to a statically defined standard invalid astrometric time.

## Additional Inherited Members

Protected Member Functions inherited from supernovas::Validating
| Validating ()
| dummy constructor;
Protected Attributes inherited from supernovas::Validating
bool | _valid = false
| the state variable.

## Detailed Description

Precise astronomical time specification, supporting all relevant astronomical timescales (UT1, UTC, TAI, GPS, TT, TDB, TCG, and TCB).

Depending on how this class is instantiated, it can support down to the nanosecond precision.

Since
  1.6

See also
  Interval, TimeAngle, Observer

## Constructor & Destructor Documentation

## Time() [1/9]

supernovas::Time::Time | ( | double | jd,
|  | int | leap_seconds,
|  | double | dUT1,
|  | enum novas_timescale | timescale = NOVAS_TT )

Instantiates an astrometric time instance with the specified time parameters.

Parameters

  jd | [day] Julian date (in the selected timescale)
  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0). It may be unused if dUT1 is NAN – see below.
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service, or NAN to fetch leap and dUT1 from IERS for dates after 1 Jan 1956, if possible and allowed.
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop(), novas_lookup_leap(), novas_fetch_eop()

References supernovas::Validating::_valid, dUT1(), jd(), leap_seconds(), and novas_set_time().

## Time() [2/9]

supernovas::Time::Time | ( | double | jd,
|  | const EOP & | eop = EOP::undefined(),
|  | enum novas_timescale | timescale = NOVAS_TT )

explicit

Instantiates an astrometric time instance with the specified time parameters.

NOTES:

- If SuperNOVAS was built without cURL support (WITHOUT_CURL or WITHOUT_LIBC build configuration options), then automatic fetching of the leap seconds and the UT1 - UTC differennce is not possible. You must set a valid EOP explicitly.

Parameters

  jd | [day] Julian date (in the selected timescale)
  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop()

References dUT1(), jd(), and leap_seconds().

## Time() [3/9]

supernovas::Time::Time | ( | long | ijd,
|  | double | fjd,
|  | int | leap_seconds,
|  | double | dUT1,
|  | enum novas_timescale | timescale = NOVAS_TT )

Instantiates an astrometric time instance with the specified time parameters.

Parameters

  ijd | [day] integer part of Julian date (in the selected timescale)
  fjd | [day] fractional part of Julian date (in the selected timescale)
  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0). It may be unused if dUT1 is NAN – see below.
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service, or NAN to fetch leap and dUT1 from IERS for dates after 1 Jan 1956, if possible and allowed.
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop(), novas_lookup_leap(), novas_fetch_eop()

References supernovas::Validating::_valid, dUT1(), leap_seconds(), and novas_set_split_time().

## Time() [4/9]

supernovas::Time::Time | ( | long | ijd,
|  | double | fjd,
|  | const EOP & | eop = EOP::undefined(),
|  | enum novas_timescale | timescale = NOVAS_TT )

Instantiates an astrometric time instance with the specified time parameters.

NOTES:

- If SuperNOVAS was built without cURL support (WITHOUT_CURL or WITHOUT_LIBC build configuration options), then automatic fetching of the leap seconds and the UT1 - UTC differennce is not possible. You must set a valid EOP explicitly.

Parameters

  ijd | [day] integer part of Julian date (in the selected timescale)
  fjd | [day] fractional part of Julian date (in the selected timescale)
  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop()

References dUT1(), and leap_seconds().

## Time() [5/9]

supernovas::Time::Time | ( | const std::string & | timestamp,
|  | int | leap_seconds,
|  | double | dUT1,
|  | enum novas_timescale | timescale = NOVAS_UTC )

Instantiates an astrometric time instance with the specified time parameters.

Parameters

  timestamp | A precision timestamp, such as an ISO 8601 timestamp.
  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0). It may be unused if dUT1 is NAN – see below.
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service, or NAN to fetch leap and dUT1 from IERS for dates after 1 Jan 1956, if possible and allowed.
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_parse_date(), novas_parse_ido_date(), novas_parse_date_format(), novas_parse_timescale() for more managed parsing from strings.
  novas_set_auto_fetch_eop(), novas_lookup_leap(), novas_fetch_eop()

References supernovas::Validating::_valid, dUT1(), leap_seconds(), and novas_set_str_time().

## Time() [6/9]

supernovas::Time::Time | ( | const std::string & | timestamp,
|  | const EOP & | eop = EOP::undefined(),
|  | enum novas_timescale | timescale = NOVAS_UTC )

explicit

Instantiates an astrometric time instance with the specified time parameters.

NOTES:

- If SuperNOVAS was built without cURL support (WITHOUT_CURL or WITHOUT_LIBC build configuration options), then automatic fetching of the leap seconds and the UT1 - UTC differennce is not possible. You must set a valid EOP explicitly.

Parameters

  timestamp | A precision timestamp, such as an ISO 8601 timestamp.
  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).
  timescale | (optional) Astronomical timescale (default: TT).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_parse_date(), novas_parse_ido_date(), novas_parse_date_format(), novas_parse_timescale() for more managed parsing from strings.
  novas_set_auto_fetch_eop()

References dUT1(), and leap_seconds().

## Time() [7/9]

supernovas::Time::Time | ( | const struct timespec * | t,
|  | int | leap_seconds,
|  | double | dUT1 )

Instantiates an astrometric time instance with the specified time parameters.

Parameters

  t | A precision POSIX standard UTC timestamp.
  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0). It may be unused if dUT1 is NAN – see below.
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service, or NAN to fetch leap and dUT1 from IERS for dates after 1 Jan 1956, if possible and allowed.

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop(), novas_lookup_leap(), novas_fetch_eop()

References supernovas::Validating::_valid, dUT1(), leap_seconds(), novas_set_unix_time(), and NOVAS_UTC.

## Time() [8/9]

supernovas::Time::Time | ( | const struct timespec * | t,
|  | const EOP & | eop = EOP::undefined() )

explicit

Instantiates an astrometric time instance with the specified time parameters.

NOTES:

- If SuperNOVAS was built without cURL support (WITHOUT_CURL or WITHOUT_LIBC build configuration options), then automatic fetching of the leap seconds and the UT1 - UTC differennce is not possible. You must set a valid EOP explicitly.

Parameters

  t | A precision POSIX standard UTC timestamp.
  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop()

References dUT1(), and leap_seconds().

## Time() [9/9]

supernovas::Time::Time | ( | const novas_timespec * | t | ) |

explicit

Instantiates an astrometric time instance with the specified SuperNOVAS C astrometric time specification data structure.

Parameters

  t | pointer to the SuperNOVAS C astrometric time specification data structure.

Since
  1.6

See also
  now(), from_mjd(), j2000(), b1950(), b1900(), hip()

References supernovas::Validating::_valid, novas_timespec::fjd_tt, novas_timespec::tt2tdb, and novas_timespec::ut1_to_tt.

## Member Function Documentation

## _novas_timespec()

const novas_timespec * supernovas::Time::_novas_timespec | ( |  | ) | const

Returns the underlying C astrometric time specification data structure.

Returns
  a pointer to the underlying C time specification data structure.

Since
  1.6

Referenced by supernovas::GeodeticObserver::eop_at(), supernovas::GeodeticObserver::gcrs_position_at(), supernovas::Observer::gcrs_position_at(), supernovas::GeodeticObserver::gcrs_velocity_at(), and supernovas::Observer::gcrs_velocity_at().

## b1900()

const Time & supernovas::Time::b1900 | ( |  | ) |

static

Returns the astrometric time for the B1900 epoch.

Returns
  the astrometric time for B1900.

Since
  1.6

See also
  b1950(), j2000(), hip()

References NOVAS_JD_B1900, and NOVAS_TT.

## b1950()

const Time & supernovas::Time::b1950 | ( |  | ) |

static

Returns the astrometric time for the B1950 epoch.

Returns
  the astrometric time for B1950.

Since
  1.6

See also
  b1900(), j2000(), hip()

References NOVAS_JD_B1950, and NOVAS_TT.

## day_of_week()

int supernovas::Time::day_of_week | ( | enum novas_timescale | timescale = NOVAS_UTC | ) | const

Returns the day of week index (1..7) for this time instance.

Parameters

  timescale | (optional) the timescale in which to return the result (default: UTC).

Returns
  The day-of-week index [1:7] in the same timescale as the input date. 1:Monday ... 7:Sunday, or else 0 if the input Julian Date is NAN.

Since
  1.6

References jd(), and novas_day_of_week().

## dUT1()

Interval supernovas::Time::dUT1 | ( |  | ) | const

Returns the UT1 - UTC time difference for this time instance, as was provided during instantiation.

Returns
  [s] The UT1 - UTC time difference.

Since
  1.6

See also
  leap_seconds()

References supernovas::Validating::is_valid().

Referenced by Time(), Time(), Time(), Time(), Time(), Time(), Time(), Time(), from_mjd(), next_moon_phase(), now(), operator-(), and shifted().

## epoch()

double supernovas::Time::epoch | ( |  | ) | const

Returns the Julian coordinate epoch year of this time instance.

Returns
  [yr] the Julian coordinate epoch (e.g. 2000.0 for J2000).

Since
  1.6

References jd(), NOVAS_JD_J2000, and NOVAS_JULIAN_YEAR_DAYS.

Referenced by to_epoch_string().

## equals() [1/2]

bool supernovas::Time::equals | ( | const Time & | time,
|  | const Interval & | precision ) const

Checks if this time instance is the same as another time within the specified precision.

Parameters

  time | the other time
  precision | (optional) The precision for the comparison (default: 1 μs).

Returns
  true if the two times are equal within the specified precision, otherwise false.

Since
  1.6

See also
  operator==(), operator!=()

References equals(), and supernovas::Interval::seconds().

## equals() [2/2]

bool supernovas::Time::equals | ( | const Time & | time,
|  | double | precision = Unit::us ) const

Checks if this time instance is the same as another time within the specified precision.

Parameters

  time | the other time
  precision | [s] (optional) The precision for the comparison (default: 1 &mus)

Returns
  true if the two times are equal within the specified precision, otherwise false.

Since
  1.6

See also
  operator==(), operator!=()

References novas_diff_time().

Referenced by equals(), operator!=(), and operator==().

## era()

TimeAngle supernovas::Time::era | ( |  | ) | const

Returns the Earth Rotation Angle (ERA), which measures the angle between the Terrestrial Intermediate Origin (TIO) and the Celestial Intermediate Origin (CIO) in the IAU 2000 convention.

Returns
  The Earth Rotation Angle (ERA) as a time-angle.

Since
  1.6

References supernovas::Unit::deg, and supernovas::Validating::is_valid().

## from_mjd() [1/2]

Time supernovas::Time::from_mjd | ( | double | mjd,
|  | const EOP & | eop = EOP::undefined(),
|  | enum novas_timescale | timescale = NOVAS_TT )

static

Returns a new astrometric time instance for a given Modified Julian Date (MJD), specified in the timescale of choice.

Parameters

  mjd | [day] Modified Julian Date, in the timescale of choice
  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).
  timescale | (optional) timescale in which MJD was specified (default: TT)

Returns
  a new astrometric time instance for the given MJD date.

Since
  1.6

See also
  Time(), now(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop()

References supernovas::EOP::dUT1(), from_mjd(), supernovas::EOP::leap_seconds(), mjd(), and supernovas::Interval::seconds().

## from_mjd() [2/2]

Time supernovas::Time::from_mjd | ( | double | mjd,
|  | int | leap_seconds,
|  | double | dUT1,
|  | enum novas_timescale | timescale = NOVAS_TT )

static

Returns a new astrometric time instance for a given Modified Julian Date (MJD), specified in the timescale of choice.

Parameters

  mjd | [day] Modified Julian Date, in the timescale of choice
  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0)
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service (default: 0.0).
  timescale | (optional) timescale in which MJD was specified (default: TT)

Returns
  a new astrometric time instance for the given MJD date.

Since
  1.6

See also
  Time(), now(), j2000(), b1950(), b1900(), hip()

References dUT1(), supernovas::Validating::is_valid(), leap_seconds(), mjd(), and NOVAS_JD_MJD0.

Referenced by from_mjd().

## gmst()

TimeAngle supernovas::Time::gmst | ( |  | ) | const

Returns the Greenwich Mean Sidereal Time (GMST) for this time instance.

Returns
  the GMST time-angle

Since
  1.6

See also
  gst(), lst()

References supernovas::Unit::hour_angle, supernovas::Validating::is_valid(), novas_get_time(), novas_gmst(), and NOVAS_UT1.

## gst()

TimeAngle supernovas::Time::gst | ( | enum novas_accuracy | accuracy = NOVAS_FULL_ACCURACY | ) | const

Returns the Greenwich (Apparent) Sidereal Time (GST / GaST) for this time instance.

Parameters

  accuracy | NOVAS_FULL_ACCURACY (0) for μs-level precision or NOVAS_REDUCED_ACCURACY (1) for &ms-level precison.

Returns
  the GST / GaST time-angle.

Since
  1.6

See also
  gmst(), lst(), era()

References supernovas::Unit::hour_angle, supernovas::Validating::is_valid(), and novas_time_gst().

## hip()

const Time & supernovas::Time::hip | ( |  | ) |

static

Returns the astrometric time for the Hipparcos catalog epoch (which is J1991.25).

Returns
  the astrometric time for the Hipparcos catalog epoch, that is J1991.25.

Since
  1.6

See also
  j2000(), b1950, b1900()

References NOVAS_JD_HIP, and NOVAS_TT.

## j2000()

const Time & supernovas::Time::j2000 | ( |  | ) |

static

Returns the astrometric time for the J2000 epoch.

Returns
  the astrometric time for J2000, that is 12:00:00 TT, 1 Jan 2000.

Since
  1.6

See also
  b1950, b1900(), hip()

References NOVAS_JD_J2000, and NOVAS_TT.

Referenced by supernovas::Ecliptic::to_mod().

## jd()

double supernovas::Time::jd | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the precise Julian Date of this time instance, in the specific timescale of choice.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the precise Julian date in the requested timescale.

Since
  1.6

See also
  jd_day(), mjd()

References jd(), novas_get_time(), and NOVAS_TIMESCALES.

Referenced by Time(), Time(), supernovas::SolarSystemSource::barycentric_at(), supernovas::Equinox::cirs(), day_of_week(), supernovas::GeodeticObserver::eop_at(), epoch(), supernovas::Orbital::from_mean_motion(), supernovas::Equinox::from_system_type(), supernovas::Observer::gcrs_position_at(), supernovas::Observer::gcrs_velocity_at(), supernovas::SolarSystemSource::helio_distance(), supernovas::SolarSystemSource::helio_rate(), jd(), supernovas::Equinox::mod(), supernovas::Orbital::moon_mean_orbit_at(), supernovas::Orbital::moon_orbit_at(), moon_phase(), next_moon_phase(), supernovas::OrbitalSystem::orbit(), supernovas::Planet::orbit(), supernovas::Orbital::position(), supernovas::SolarSystemSource::solar_power(), to_calendar_date(), supernovas::Ecliptic::to_mod(), supernovas::Horizontal::to_refracted(), supernovas::Ecliptic::to_tod(), supernovas::Horizontal::to_unrefracted(), supernovas::Equinox::tod(), and supernovas::Orbital::velocity().

## jd_day()

long supernovas::Time::jd_day | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the integer Julian day of this time instance, in the specific timescale of choice.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the integer Julian day in the requested timescale.

Since
  1.6

See also
  jd_frac(), mjd_day(), mjd(), jd()

References novas_get_split_time(), and NOVAS_TIMESCALES.

## jd_frac()

double supernovas::Time::jd_frac | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the factional Julian Day (MJD) of this time instance, in the specific timescale of choice.

0h in Julian dates is at noon.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the fractional part of the Julian Day in the requested timescale.

Since
  1.6

See also
  mjd_frac(), jd_day(), jd()

References novas_get_split_time(), and NOVAS_TIMESCALES.

Referenced by mjd_frac().

## leap_seconds()

int supernovas::Time::leap_seconds | ( |  | ) | const

Returns the leap seconds for this time instance, as was provided during instantiation.

Returns
  [s] the leap seconds (TAI - UTC).

Since
  1.6

See also
  dUT1()

References novas_time_leap().

Referenced by Time(), Time(), Time(), Time(), Time(), Time(), Time(), Time(), from_mjd(), next_moon_phase(), now(), operator-(), and shifted().

## lst()

TimeAngle supernovas::Time::lst | ( | const Site & | site,
|  | enum novas_accuracy | accuracy = NOVAS_FULL_ACCURACY ) const

Returns the Local (Apparent) Sidereal Time for this time instance.

Parameters

  site | observing site
  accuracy | (optional) NOVAS_FULL_ACCURACY (0; default) for μs-level precision or NOVAS_REDUCED_ACCURACY (1) for &ms-level precison.

Returns
  the LST / LaST time-angle.

Since
  1.6

See also
  gst(), era()

References supernovas::Angle::deg(), supernovas::Unit::hour_angle, supernovas::Validating::is_valid(), supernovas::Site::longitude(), and novas_time_lst().

## mjd()

double supernovas::Time::mjd | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the precise Modified Julian Date (MJD) this time instance, in the specific timescale of choice.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the precise Modifie Julian Date (MJD) in the requested timescale.

Since
  1.6

See also
  mjd_day(), jd()

References novas_get_split_time(), NOVAS_JD_MJD0, and NOVAS_TIMESCALES.

Referenced by from_mjd(), from_mjd(), and operator-().

## mjd_day()

long supernovas::Time::mjd_day | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the integer Modified Julian Day (MJD) of this time instance, in the specific timescale of choice.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the integer Modified Julian Day (MJD) in the requested timescale.

Since
  1.6

See also
  jd_frac(), jd_day(), mjd(), jd()

References novas_get_split_time(), and NOVAS_TIMESCALES.

## mjd_frac()

double supernovas::Time::mjd_frac | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the integer Modified Julian Day (MJD) of this time instance, in the specific timescale of choice.

0h in MJD is at midnight.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  [day] the fractional part of the Julian Day in the requested timescale.

Since
  1.6

See also
  jd_frac(), mjd_day(), mjd()

References jd_frac(), and NOVAS_TIMESCALES.

Referenced by time_of_day().

## moon_phase()

Angle supernovas::Time::moon_phase | ( |  | ) | const

Returns the phase of the Moon at this time instance.

Returns
  The Moon's phase, or more precisely the ecliptic longitude difference between the Sun and the Moon, as seen from the geocenter. 0°: New Moon, 90°: 1st quarter, +/- 180° Full Moon, -90°: 3rd quarter, or NAN if the solution failed to converge (errno will be set to ECANCELED).

Since
  1.6

See also
  next_moon_phase()

References supernovas::Unit::deg, supernovas::Validating::is_valid(), jd(), novas_moon_phase(), and NOVAS_TDB.

## next_moon_phase()

Time supernovas::Time::next_moon_phase | ( | const Angle & | phase | ) | const

Returns the next time, after this time instance, when the Moon will be in the specified phase.

Parameters

  phase | The Moon's phase. 0°: New Moon, 90°: 1st quarter, +/- 180° Full Moon, -90°: 3rd quarter.

Returns
  The next time the Moon will be in the specified phase.

Since
  1.6

See also
  moon_phase()

References supernovas::Angle::deg(), dUT1(), supernovas::Validating::is_valid(), jd(), leap_seconds(), novas_next_moon_phase(), and NOVAS_TDB.

## now() [1/2]

Time supernovas::Time::now | ( | const EOP & | eop = EOP::undefined() | ) |

static

Resturns a new astrometric time instance for the current time.

It is only as accurate as the system clock, and its precision may be limited by the resolution of the system clock also. Be sure that your computer is well synchronized to a trustworthy time server, preferably on a local network, such as an ntp server with a GPS receiver.

NOTES:

- If SuperNOVAS was built without libc support (WITHOUT_LIBC build configuration option), then this function will always return an invalid (undefined) time (errno set to ENOSYS).
- If SuperNOVAS was built without cURL support (WITHOUT_CURL build configuration option), then automatic fetching of the leap seconds and the UT1 - UTC differennce is not possible. You must set a valid EOP explicitly.

Parameters

  eop | (optional) Earth Orientation Parameters (EOP) values, e.g. obtained from IERS, or EOP::undefined() to fetch it from IERS, if possible and allowed (default: undefined).

Returns
  a new astrometric time corresponding to the current system time.

Since
  1.6

See also
  Time(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop()

References supernovas::EOP::dUT1(), supernovas::EOP::leap_seconds(), now(), and supernovas::Interval::seconds().

## now() [2/2]

Time supernovas::Time::now | ( | int | leap_seconds,
|  | double | dUT1 )

static

Resturns a new astrometric time instance for the current time.

It is only as accurate as the system clock, and its precision may be limited by the resolution of the system clock also. Be sure that your computer is well synchronized to a trustworthy time server, preferably on a local network, such as an ntp server with a GPS receiver.

NOTES:

- If SuperNOVAS was built with the WITHOUT_SYSTEM_CLOCK preprocessor flag (or with the WITHOUT_LIBC build configuration option), then this function will always return an invalid / undefined time (errno set to ENOSYS). You may want to set the time explicitly with one of the constructors or other static methods instead.

Parameters

  leap_seconds | [s] leap seconds, that is TAI - UTC (default: 0). It may be unused if dUT1 is NAN – see below.
  dUT1 | [s] UT1 - UTC time difference, e.g. from the IERS Bulletins or service, or NAN to fetch leap and dUT1 from IERS for dates after 1 Jan 1956, if possible and allowed.

Returns
  a new astrometric time corresponding to the current system time.

Since
  1.7

See also
  Time(), from_mjd(), j2000(), b1950(), b1900(), hip()
  novas_set_auto_fetch_eop(), novas_lookup_leap(), novas_fetch_eop()

References dUT1(), supernovas::Validating::is_valid(), leap_seconds(), and novas_set_current_time().

Referenced by now().

## offset_from()

Interval supernovas::Time::offset_from | ( | const Time & | time,
|  | enum novas_timescale | timescale = NOVAS_TT ) const

Returns the difference of this time from the specified other time, in the specified timescale.

All timescales are supported.

Parameters

  time | the other time
  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  the difference between this time and the argument time in the specified timescale.

Since
  1.6

See also
  operator-(), shifted()

References supernovas::Validating::is_valid(), and novas_diff_time_scale().

Referenced by operator-().

## operator!=()

bool supernovas::Time::operator!= | ( | const Time & | time | ) | const

Checks if this time instance differs from another time by more than 1 μs.

Parameters

  time | the other time

Returns
  true if the two times differ by more than 1 μs.

Since
  1.6

See also
  operator==(), operator!=()

References equals().

## operator+() [1/2]

Time supernovas::Time::operator+ | ( | const Interval & | offset | ) | const

Returns an offset time in the forward direction.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  offset | the offset interval (in forward direction).

Returns
  a new time that is offset from this one by the specified interval.

Since
  1.6

See also
  operator-(), shifted()

References supernovas::Interval::seconds().

## operator+() [2/2]

Time supernovas::Time::operator+ | ( | double | seconds | ) | const

Returns an offset time.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  seconds | [s] the offset interval

Returns
  a new time that is offset from this one by the specified interval in the forward direction.

Since
  1.6

See also
  operator+(), shifted()

References shifted().

## operator-() [1/4]

Interval supernovas::Time::operator- | ( | const CalendarDate & | other | ) | const

References supernovas::Calendar::astronomical(), dUT1(), leap_seconds(), mjd(), NOVAS_FULL_ACCURACY, NOVAS_TT, NOVAS_UTC, supernovas::EOP::undefined(), and supernovas::Unit::us.

## operator-() [2/4]

Time supernovas::Time::operator- | ( | const Interval & | offset | ) | const

Returns an offset time.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  offset | the offset interval

Returns
  a new time that is offset from this one by the specified interval in the reverse direction (backwards in time).

Since
  1.6

See also
  operator+(), shifted()

References supernovas::Interval::seconds().

## operator-() [3/4]

Interval supernovas::Time::operator- | ( | const Time & | r | ) | const

Returns the difference of this time from the specified other time, in regular Earth-based time measures (GPS, TAI, TT – and also UTC assuming no change in leap seconds).

Parameters

  r | the other time

Returns
  the difference between this time and the argument in regular Earth-based timescales.

Since
  1.6

See also
  offset_from()

References supernovas::Validating::is_valid(), and offset_from().

## operator-() [4/4]

Time supernovas::Time::operator- | ( | double | seconds | ) | const

Returns an offset time in the backwards direction.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  seconds | [s] the offset interval (backwards direction).

Returns
  a new time that is offset from this one by the specified interval in the reverse direction (backwards in time).

Since
  1.6

See also
  operator+(), shifted()

References shifted().

## operator<()

bool supernovas::Time::operator< | ( | const Time & | r | ) | const

Checks if this time is prior to the specified other time, at the full precision of the representation.

Parameters

  r | the other time

Returns
  true if this time instance is before the specified other time, or else false.

Since
  1.6

See also
  operator<=(), operator>(), operator>=()

References novas_diff_time().

## operator<=()

bool supernovas::Time::operator<= | ( | const Time & | r | ) | const

Checks if this time is the same as or before the specified other time, at 1 μs resolution.

Parameters

  r | the other time

Returns
  true if this time instance is the same as or before the specified other time, or else false.

See also
  operator<(), operator>=(), operator>()

References novas_diff_time(), and supernovas::Unit::us.

## operator==()

bool supernovas::Time::operator== | ( | const Time & | time | ) | const

Checks if this time instance is the same as another time within 1 μs.

Parameters

  time | the other time

Returns
  true if the two times are equal within 1 μs, otherwise false.

Since
  1.6

See also
  equals(), operator!=()

References equals().

## operator>()

bool supernovas::Time::operator> | ( | const Time & | r | ) | const

Checks if this time is after to the specified other time, at the full precision of the representation.

Parameters

  r | the other time

Returns
  true if this time instance is after the specified other time, or else false.

Since
  1.6

See also
  operator>=(), operator<(), operator<=()

## operator>=()

bool supernovas::Time::operator>= | ( | const Time & | r | ) | const

Checks if this time is the same as or after the specified other time, at 1 μs resolution.

Parameters

  r | the other time

Returns
  true if this time instance is the same as or after the specified other time, or else false.

Since
  1.6

See also
  operator<(), operator>=(), operator>()

## shifted() [1/2]

Time supernovas::Time::shifted | ( | const Interval & | offset,
|  | enum novas_timescale | timescale = NOVAS_TT ) const

Returns an offset time.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  offset | the offset interval in a regular Earth-based timescale (GPS, TAI, TT – or UTC assuming no change in leap seconds).
  timescale | (optional) timescale in which offset time is given (default: TT / TAI / GPS).

Returns
  a new time that is offset from this one by the specified interval in the specified timescale

Since
  1.6

See also
  operator+(), offset_from()

References supernovas::Interval::seconds(), and shifted().

## shifted() [2/2]

Time supernovas::Time::shifted | ( | double | seconds,
|  | enum novas_timescale | timescale = NOVAS_TT ) const

Returns an offset time.

It assumes that the leap seconds and UT1 - UTC time difference of this time instance is also valid for the offset time, which should be true typically for reasonably small time offsets.

Parameters

  seconds | [s] the offset interval in a regular Earth-based timescale (GPS, TAI, TT – or UTC assuming no change in leap seconds).
  timescale | (optional) timescale in which offset time is given (default: TT / TAI / GPS).

Returns
  a new time that is offset from this one by the specified interval in the specified timescale.

Since
  1.6

See also
  operator+(), offset_from()

References supernovas::Unit::day, dUT1(), supernovas::Validating::is_valid(), leap_seconds(), novas_get_split_time(), novas_set_split_time(), and undefined().

Referenced by operator+(), operator-(), and shifted().

## time_of_day()

TimeAngle supernovas::Time::time_of_day | ( | enum novas_timescale | timescale = NOVAS_TT | ) | const

Returns the time of (calendar) day of this time instance in the timescale of choice.

Parameters

  timescale | (optional) the timescale in which to return the result (default: TT).

Returns
  The time of day in the requested timescale.

Since
  1.6

See also
  jd_time_of_day()

References supernovas::Validating::is_valid(), mjd_frac(), and TWOPI.

## timescale_offset()

Interval supernovas::Time::timescale_offset | ( | enum novas_timescale | timescale,
|  | enum novas_timescale | ref_scale = NOVAS_TT ) const

Returns the time difference between two timescales at this specific time instance.

Parameters

  timescale | a timescale
  ref_scale | (optional) the reference timescale (default: TT).

Returns
  The difference in the time expressed in the specified timescale vs the reference timescale.

Since
  1.6

See also
  Frame::clock_skew()

References supernovas::Validating::is_valid(), and novas_timescale_offset().

## to_calendar_date() [1/2]

CalendarDate supernovas::Time::to_calendar_date | ( | const Calendar & | calendar = Calendar::astronomical(),
|  | enum novas_timescale | timescale = NOVAS_UTC ) const

Returns a calendar date, in the calendar of choice, and in the timescale of choice, for time instance.

Parameters

  calendar | (optional) Calendar in which to represent this time instance (default: astronomical)
  timescale | (optional) timescale in which MJD was specified (default: TT)

Returns
  the calendar date in the desired calendar and timescale of choice.

Since
  1.6

References supernovas::Calendar::date(), supernovas::Validating::is_valid(), and jd().

Referenced by to_calendar_date().

## to_calendar_date() [2/2]

CalendarDate supernovas::Time::to_calendar_date | ( | enum novas_timescale | timescale | ) | const

Returns the astronomical calendar date instance for this astrometric time.

The astronomical calendar is the conventional calendar of date, which is the Gregorian calendar after the Gregorian calendar reform if 1582, and the Roman calendar prior to that.

Parameters

  timescale | timescale in which MJD was specified (default: TT)

Returns
  the astronomical calendar date in the timescale of choice.

Since
  1.6

References supernovas::Calendar::astronomical(), and to_calendar_date().

## to_epoch_string()

std::string supernovas::Time::to_epoch_string | ( | int | decimals = 2 | ) | const

Returns the string representation of the Julian coordinate epoch corresponding to this timestamp.

Parameters

  decimals | (optional) number of decimal places to show on the year (default: 2).

Returns
  a new string representing the Julian coordinate epoch of this time with the requested precision, or "<invalid epoch>"

Since
  1.6

References epoch(), and supernovas::Validating::is_valid().

## to_iso_string()

std::string supernovas::Time::to_iso_string | ( |  | ) | const

Returns an ISO 8601 timestamp for this time instance.

Returns
  a new string containing the ISO 8601 timestamp, or "<invalid time>".

Since
  1.6

See also
  to_string()

References supernovas::Validating::is_valid(), and novas_iso_timestamp().

## to_string()

std::string supernovas::Time::to_string | ( | enum novas_timescale | timescale = NOVAS_UTC | ) | const

Returns a string representation (a timestamp) of this time instance.

Parameters

  timescale | (optional) the timescale in which to represent time (default: UTC).

Returns
  a new string containing the timestamp, or "<invalid time>".

Since
  1.6

See also
  to_iso_timestamp(), to_epoch_string()

References supernovas::Validating::is_valid(), and novas_timestamp().

## undefined()

const Time & supernovas::Time::undefined | ( |  | ) |

static

Returns a reference to a statically defined standard invalid astrometric time.

This invalid time may be used inside any object that is invalid itself.

Returns
  a reference to a static standard invalid astrometric time.

Since
  1.6

Referenced by shifted().

## unix_time()

time_t supernovas::Time::unix_time | ( | long * | nanos = NULL | ) | const

Returns the precise UNIX time (UTC) corresponding to this time instance.

Parameters

  [out] | nanos | [ns] (optional) pointer to value in which to return the sub-second component, or NULL if not required.

Returns
  [s] the integer UNIX seconds (UTC) of this time instance.

Since
  1.6

References novas_get_unix_time().