HOPS
HOPS class reference
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
hops::hops_clock Class Reference

a clock for hops-time stamps, measures time in (UTC) nanoseconds since J2000 epoch. Functionality modelled on the gps_clock from the 'date' library (requires the timezone tz library too). Relys on the H. Hinnant date library (and tzdata), this library is expected to be adopted into cxx-20 standard More...

#include <MHO_Clock.hh>

Public Types

using duration = std::chrono::nanoseconds
 
using period = duration::period
 
using rep = duration::rep
 
using time_point = std::chrono::time_point< hops_clock, std::chrono::nanoseconds >
 

Public Member Functions

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_gps (const date::gps_time< Duration > &t) NOEXCEPT
 Converts GPS time to UTC and updates hops clock without exception. More...
 
template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_local (const date::local_time< Duration > &t) NOEXCEPT
 Calculates time difference between two UTC time points considering leap seconds. More...
 
template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_sys (const date::sys_time< Duration > &t) NOEXCEPT
 Converts system time to UTC clock time and returns it. More...
 
template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_tai (const date::tai_time< Duration > &t) NOEXCEPT
 Converts TAI time to UTC and updates hops clock. More...
 
template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_utc (const date::utc_time< Duration > &t) NOEXCEPT
 Converts UTC time to hops clock time. More...
 
template<class Duration >
date::gps_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_gps (const hops_time< Duration > &t) NOEXCEPT
 Converts hops_time to GPS time using UTC conversion. More...
 
template<class Duration >
date::local_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_local (const hops_time< Duration > &t) NOEXCEPT
 Converts a UTC time to local time using hops_clock. More...
 
template<class Duration >
date::sys_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_sys (const hops_time< Duration > &t) NOEXCEPT
 Converts a hops_time to system time using UTC clock. More...
 
template<class Duration >
date::tai_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_tai (const hops_time< Duration > &t) NOEXCEPT
 Converts a Hops time to TAI (International Atomic Time). More...
 
template<class Duration >
date::utc_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_utc (const hops_time< Duration > &t) NOEXCEPT
 Converts a time duration to UTC using Hops clock epoch. More...
 

Static Public Member Functions

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_gps (const std::chrono::time_point< date::gps_clock, Duration > &) NOEXCEPT
 Converts GPS time to Hops clock time. More...
 
static time_point from_hops_format (const std::string &timestamp)
 Converts a timestamp string in HOPS format to a time_point object. More...
 
static time_point from_iso8601_format (const std::string &timestamp)
 Converts an ISO8601 formatted timestamp string to a hops_clock time_point object. More...
 
static time_point from_legacy_hops_date (legacy_hops_date &ldate)
 Converts a legacy hops data struct to a hops_clock time_point. More...
 
template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_local (const std::chrono::time_point< date::local_t, Duration > &) NOEXCEPT
 Calculates time difference between input local time and Hops epoch in UTC. More...
 
static time_point from_mjd (const time_point &mjd_epoch, const double &epoch_offset, const double &mjd)
 Converts a Modified Julian date (floating point epoch and day) timestamp to a hops_clock time_point. More...
 
template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_sys (const std::chrono::time_point< std::chrono::system_clock, Duration > &) NOEXCEPT
 Converts a system time point to UTC and returns the corresponding hops clock time. More...
 
template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_tai (const std::chrono::time_point< date::tai_clock, Duration > &) NOEXCEPT
 Converts a TAI time point to UTC and returns the corresponding Hops clock time. More...
 
template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_utc (const std::chrono::time_point< date::utc_clock, Duration > &) NOEXCEPT
 Converts UTC time point to hops_clock time point. More...
 
static time_point from_vdif_format (int &vdif_epoch, int &vdif_seconds)
 Converts a VDIF (epoch, second) timestamp to a hops_clock time_point. More...
 
static time_point from_vex_format (const std::string &timestamp)
 Converts a VEX-style formatted string (e.g. 2019y106d18h30m15s) to a hops_clock time_point. More...
 
static time_point from_year_fpday (int year, double floating_point_days)
 Converts a year + floating point day since start of the year to a hops_clock time_point, needed for ad_hoc flag files (time-stamps are given in floating-point days) More...
 
static time_point get_hops_epoch ()
 returns the hops_clock epoch as a hops_clock time_point More...
 
static date::utc_time< std::chrono::nanoseconds > get_hops_epoch_utc ()
 returns the hops_clock epoch as a utc_time time_point More...
 
static std::chrono::seconds get_leap_seconds_between (const time_point &t_start, const time_point &t_end)
 calculates the number of leap seconds inserted between two hops time points (UTC based clock) More...
 
static time_point now ()
 Returns current time as a time_point using hops_clock's epoch. More...
 
template<typename Duration >
static std::chrono::time_point< date::gps_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_gps (const std::chrono::time_point< hops_clock, Duration > &) NOEXCEPT
 Converts a time point to GPS clock time. More...
 
static std::string to_hops_format (const time_point &tp)
 Converts a time_point to HOPS format string. More...
 
static std::string to_iso8601_format (const time_point &tp)
 Converts a time_point to ISO8601 formatted string. More...
 
static legacy_hops_date to_legacy_hops_date (const time_point &tp)
 Converts a hops_clock time_point to a legacy hops data struct. More...
 
template<typename Duration >
static std::chrono::time_point< date::local_t, typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_local (const std::chrono::time_point< hops_clock, Duration > &) NOEXCEPT
 Converts a global time point to local time. More...
 
static double to_mjd (const time_point &mjd_epoch, const double &epoch_offset, const time_point &tp)
 Converts a hops_clock time_point to a Modified Julian date (floating point day) timestamp, givent the specified epoch. More...
 
template<typename Duration >
static std::chrono::time_point< std::chrono::system_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_sys (const std::chrono::time_point< hops_clock, Duration > &) NOEXCEPT
 Converts a time point from hops_clock to system clock. More...
 
template<typename Duration >
static std::chrono::time_point< date::tai_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_tai (const std::chrono::time_point< hops_clock, Duration > &) NOEXCEPT
 Converts a time point from hops_clock to TAI (International Atomic Time). More...
 
template<typename Duration >
static std::chrono::time_point< date::utc_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > to_utc (const std::chrono::time_point< hops_clock, Duration > &) NOEXCEPT
 Converts a time point to UTC using hops_clock and Duration. More...
 
static void to_vdif_format (const time_point &tp, int &vdif_epoch, int &vdif_second)
 Converts a hops_clock time_point to a VDIF (epoch, second) timestamp. More...
 
static std::string to_vex_format (const time_point &tp, bool truncate_to_nearest_second=false)
 Converts a hops_clock time_point to VEX-style formatted string (e.g. 2019y106d18h30m15s) More...
 
static void to_year_fpday (const time_point &tp, int &year, double &floating_point_days)
 Converts a hops_clock time_point to a floating point day since start of the year needed for ad_hoc flag files (time-stamps are given in floating-point days) More...
 

Static Public Attributes

static const bool is_steady = false
 

Detailed Description

a clock for hops-time stamps, measures time in (UTC) nanoseconds since J2000 epoch. Functionality modelled on the gps_clock from the 'date' library (requires the timezone tz library too). Relys on the H. Hinnant date library (and tzdata), this library is expected to be adopted into cxx-20 standard

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Wed May 18 16:46:16 2022 -0400

Member Typedef Documentation

◆ duration

using hops::hops_clock::duration = std::chrono::nanoseconds

◆ period

using hops::hops_clock::period = duration::period

◆ rep

using hops::hops_clock::rep = duration::rep

◆ time_point

using hops::hops_clock::time_point = std::chrono::time_point< hops_clock, std::chrono::nanoseconds >

Member Function Documentation

◆ from_gps() [1/2]

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_gps ( const date::gps_time< Duration > &  t)
inline

Converts GPS time to UTC and updates hops clock without exception.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput GPS time in floating-point days.

◆ from_gps() [2/2]

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_gps ( const std::chrono::time_point< date::gps_clock, Duration > &  )
static

Converts GPS time to Hops clock time.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< date::gps_clock, Duration

◆ from_hops_format()

hops_clock::time_point hops::hops_clock::from_hops_format ( const std::string &  timestamp)
inlinestatic

Converts a timestamp string in HOPS format to a time_point object.

Function hops_clock::from_hops_format.

Parameters
timestampInput timestamp string in HOPS format.
Returns
time_point representing the parsed timestamp or epoch start if parsing fails.
Note
This is a static function.
Parameters
timestamp(const std::string&)
Returns
Return value (hops_clock::time_point)

◆ from_iso8601_format()

hops_clock::time_point hops::hops_clock::from_iso8601_format ( const std::string &  timestamp)
inlinestatic

Converts an ISO8601 formatted timestamp string to a hops_clock time_point object.

Converts an ISO8601 formatted timestamp string to hops_clock::time_point.

Parameters
timestampInput timestamp string in ISO8601 format
Returns
Time point object representing the parsed timestamp
Note
This is a static function.
Parameters
timestampInput timestamp string in ISO8601 format
Returns
hops_clock::time_point representing the parsed timestamp

◆ from_legacy_hops_date()

hops_clock::time_point hops::hops_clock::from_legacy_hops_date ( legacy_hops_date ldate)
inlinestatic

Converts a legacy hops data struct to a hops_clock time_point.

Parameters
ldate(legacy_hops_date)
Returns
time_point
Note
This is a static function.

◆ from_local() [1/2]

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_local ( const date::local_time< Duration > &  t)
inline

Calculates time difference between two UTC time points considering leap seconds.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput local time to convert to UTC.

◆ from_local() [2/2]

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_local ( const std::chrono::time_point< date::local_t, Duration > &  )
static

Calculates time difference between input local time and Hops epoch in UTC.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< date::local_t, Duration

◆ from_mjd()

hops_clock::time_point hops::hops_clock::from_mjd ( const time_point mjd_epoch,
const double &  epoch_offset,
const double &  mjd 
)
inlinestatic

Converts a Modified Julian date (floating point epoch and day) timestamp to a hops_clock time_point.

Parameters
mjd_epoch(time_point)
epoch_offset(double&)
mjd(double&)
Returns
time_point
Note
This is a static function.

◆ from_sys() [1/2]

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_sys ( const date::sys_time< Duration > &  t)
inline

Converts system time to UTC clock time and returns it.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput system time in floating-point days.

◆ from_sys() [2/2]

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_sys ( const std::chrono::time_point< std::chrono::system_clock, Duration > &  )
static

Converts a system time point to UTC and returns the corresponding hops clock time.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< std::chrono::system_clock, Duration

◆ from_tai() [1/2]

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_tai ( const date::tai_time< Duration > &  t)
inline

Converts TAI time to UTC and updates hops clock.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput TAI time

◆ from_tai() [2/2]

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_tai ( const std::chrono::time_point< date::tai_clock, Duration > &  )
static

Converts a TAI time point to UTC and returns the corresponding Hops clock time.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< date::tai_clock, Duration

◆ from_utc() [1/2]

template<class Duration >
hops_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_utc ( const date::utc_time< Duration > &  t)
inline

Converts UTC time to hops clock time.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput UTC time.

◆ from_utc() [2/2]

template<typename Duration >
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::from_utc ( const std::chrono::time_point< date::utc_clock, Duration > &  )
static

Converts UTC time point to hops_clock time point.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< date::utc_clock, Duration

◆ from_vdif_format()

hops_clock::time_point hops::hops_clock::from_vdif_format ( int &  vdif_epoch,
int &  vdif_seconds 
)
inlinestatic

Converts a VDIF (epoch, second) timestamp to a hops_clock time_point.

Parameters
vdif_epoch(int)
vdif_seconds(int)
Returns
time_point
Note
This is a static function.

◆ from_vex_format()

hops_clock::time_point hops::hops_clock::from_vex_format ( const std::string &  timestamp)
inlinestatic

Converts a VEX-style formatted string (e.g. 2019y106d18h30m15s) to a hops_clock time_point.

Parameters
timestampVEX formatted string representation of time
Returns
time_point
Note
This is a static function.

◆ from_year_fpday()

hops_clock::time_point hops::hops_clock::from_year_fpday ( int  year,
double  floating_point_days 
)
inlinestatic

Converts a year + floating point day since start of the year to a hops_clock time_point, needed for ad_hoc flag files (time-stamps are given in floating-point days)

Parameters
year(int)
floating_point_days(double) - days since start of the year
Returns
time_point
Note
This is a static function.

◆ get_hops_epoch()

static time_point hops::hops_clock::get_hops_epoch ( )
inlinestatic

returns the hops_clock epoch as a hops_clock time_point

◆ get_hops_epoch_utc()

static date::utc_time< std::chrono::nanoseconds > hops::hops_clock::get_hops_epoch_utc ( )
inlinestatic

returns the hops_clock epoch as a utc_time time_point

◆ get_leap_seconds_between()

static std::chrono::seconds hops::hops_clock::get_leap_seconds_between ( const time_point t_start,
const time_point t_end 
)
inlinestatic

calculates the number of leap seconds inserted between two hops time points (UTC based clock)

◆ now()

hops_clock::time_point hops::hops_clock::now ( )
inlinestatic

Returns current time as a time_point using hops_clock's epoch.

Returns the current time point in HOPS clock format.

Returns
time_point representing current time in hops_clock's epoch.
Note
This is a static function.
Returns
Current time point as hops_clock::time_point.

◆ to_gps() [1/2]

template<class Duration >
date::gps_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_gps ( const hops_time< Duration > &  t)
inline

Converts hops_time to GPS time using UTC conversion.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput hops_time with Duration template parameter

◆ to_gps() [2/2]

template<typename Duration >
static std::chrono::time_point< date::gps_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_gps ( const std::chrono::time_point< hops_clock, Duration > &  )
static

Converts a time point to GPS clock time.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< hops_clock, Duration

◆ to_hops_format()

std::string hops::hops_clock::to_hops_format ( const time_point tp)
inlinestatic

Converts a time_point to HOPS format string.

Parameters
tpInput time_point to convert
Returns
String representation of tp in HOPS format
Note
This is a static function.
Parameters
tpInput time_point to convert
Returns
String representation of tp in HOPS format

◆ to_iso8601_format()

std::string hops::hops_clock::to_iso8601_format ( const time_point tp)
inlinestatic

Converts a time_point to ISO8601 formatted string.

Parameters
tpInput time_point to be converted
Returns
ISO8601 formatted string representation of tp
Note
This is a static function.
Parameters
tpInput time_point to be converted
Returns
ISO8601 formatted string representation of tp

◆ to_legacy_hops_date()

legacy_hops_date hops::hops_clock::to_legacy_hops_date ( const time_point tp)
inlinestatic

Converts a hops_clock time_point to a legacy hops data struct.

Parameters
tp(time_point)
Returns
legacy_hops_date struct
Note
This is a static function.

◆ to_local() [1/2]

template<class Duration >
date::local_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_local ( const hops_time< Duration > &  t)
inline

Converts a UTC time to local time using hops_clock.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput UTC time in hops_time format

◆ to_local() [2/2]

template<typename Duration >
static std::chrono::time_point< date::local_t, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_local ( const std::chrono::time_point< hops_clock, Duration > &  )
static

Converts a global time point to local time.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< hops_clock, Duration

◆ to_mjd()

double hops::hops_clock::to_mjd ( const time_point mjd_epoch,
const double &  epoch_offset,
const time_point tp 
)
inlinestatic

Converts a hops_clock time_point to a Modified Julian date (floating point day) timestamp, givent the specified epoch.

Parameters
mjd_epoch(time_point)
epoch_offset(double&)
tp(time_point&)
Returns
MJD (double)
Note
This is a static function.

◆ to_sys() [1/2]

template<class Duration >
date::sys_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_sys ( const hops_time< Duration > &  t)
inline

Converts a hops_time to system time using UTC clock.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput hops_time with Duration template parameter

◆ to_sys() [2/2]

template<typename Duration >
static std::chrono::time_point< std::chrono::system_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_sys ( const std::chrono::time_point< hops_clock, Duration > &  )
static

Converts a time point from hops_clock to system clock.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< hops_clock, Duration

◆ to_tai() [1/2]

template<class Duration >
date::tai_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_tai ( const hops_time< Duration > &  t)
inline

Converts a Hops time to TAI (International Atomic Time).

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput Hops time in UTC

◆ to_tai() [2/2]

template<typename Duration >
static std::chrono::time_point< date::tai_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_tai ( const std::chrono::time_point< hops_clock, Duration > &  )
static

Converts a time point from hops_clock to TAI (International Atomic Time).

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< hops_clock, Duration

◆ to_utc() [1/2]

template<class Duration >
date::utc_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_utc ( const hops_time< Duration > &  t)
inline

Converts a time duration to UTC using Hops clock epoch.

Template Parameters
DurationTemplate parameter Duration
Parameters
tInput time duration in specified Duration.

◆ to_utc() [2/2]

template<typename Duration >
static std::chrono::time_point< date::utc_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > hops::hops_clock::to_utc ( const std::chrono::time_point< hops_clock, Duration > &  )
static

Converts a time point to UTC using hops_clock and Duration.

Template Parameters
DurationTemplate parameter Duration
Parameters
&Parameter & of type const std::chrono::time_point< hops_clock, Duration

◆ to_vdif_format()

void hops::hops_clock::to_vdif_format ( const time_point tp,
int &  vdif_epoch,
int &  vdif_second 
)
inlinestatic

Converts a hops_clock time_point to a VDIF (epoch, second) timestamp.

Parameters
tp(time_point)
referenceto vdif_epoch (int&)
referenceto vdif_seconds (int&)
Returns
time_point
Note
This is a static function.

◆ to_vex_format()

std::string hops::hops_clock::to_vex_format ( const time_point tp,
bool  truncate_to_nearest_second = false 
)
inlinestatic

Converts a hops_clock time_point to VEX-style formatted string (e.g. 2019y106d18h30m15s)

Parameters
tpInput time_point to be converted
truncate_to_nearest_second(bool) optionally truncate the time-point to the nearest second
Returns
VEX formatted string representation of tp
Note
This is a static function.

◆ to_year_fpday()

void hops::hops_clock::to_year_fpday ( const time_point tp,
int &  year,
double &  floating_point_days 
)
inlinestatic

Converts a hops_clock time_point to a floating point day since start of the year needed for ad_hoc flag files (time-stamps are given in floating-point days)

Parameters
tpInput time_point to be converted
year(int&)
floating_point_days(double&) - days since start of the year
Note
This is a static function.

Member Data Documentation

◆ is_steady

const bool hops::hops_clock::is_steady = false
static

The documentation for this class was generated from the following file: