11 #include "date/date.h"
21 #ifdef HOPS_USE_INTERNAL_LEAP_SECONDS
31 #define J2000_TAI_EPOCH "2000-01-01 11:59:27.816"
32 #define ISO8601_UTC_FORMAT "%FT%TZ"
33 #define HOPS_TIMESTAMP_PREFIX "HOPS-J2000"
34 #define HOPS_TIME_DELIM "|"
35 #define HOPS_TIME_UNIT "ns"
36 #define NANOSEC_TO_SEC 1e-9
37 #define SEC_TO_NANOSEC 1000000000
38 #define JD_TO_SEC 86400.0
39 #define MINUTE_TO_SEC 60.0
40 #define HOUR_TO_SEC 3600.0
46 #ifdef HOPS_USE_INTERNAL_LEAP_SECONDS
47 namespace hops_tz =
hops;
49 namespace hops_tz =
date;
69 using rep = duration::rep;
71 using time_point = std::chrono::time_point< hops_clock, std::chrono::nanoseconds >;
88 template<
typename Duration >
89 static std::chrono::time_point< hops_tz::utc_clock,
90 typename std::common_type< Duration, std::chrono::nanoseconds >::type >
91 to_utc(
const std::chrono::time_point< hops_clock, Duration >&) NOEXCEPT;
99 template<
typename Duration >
100 static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
101 from_utc(
const std::chrono::time_point< hops_tz::utc_clock, Duration >&) NOEXCEPT;
109 template<
typename Duration >
110 static std::chrono::time_point< hops_tz::tai_clock,
111 typename std::common_type< Duration, std::chrono::nanoseconds >::type >
112 to_tai(
const std::chrono::time_point< hops_clock, Duration >&) NOEXCEPT;
120 template<
typename Duration >
121 static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
122 from_tai(
const std::chrono::time_point< hops_tz::tai_clock, Duration >&) NOEXCEPT;
130 template<
typename Duration >
131 static std::chrono::time_point< hops_tz::gps_clock,
132 typename std::common_type< Duration, std::chrono::nanoseconds >::type >
133 to_gps(
const std::chrono::time_point< hops_clock, Duration >&) NOEXCEPT;
141 template<
typename Duration >
142 static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
143 from_gps(
const std::chrono::time_point< hops_tz::gps_clock, Duration >&) NOEXCEPT;
151 template<
typename Duration >
152 static std::chrono::time_point< std::chrono::system_clock,
153 typename std::common_type< Duration, std::chrono::nanoseconds >::type >
154 to_sys(
const std::chrono::time_point< hops_clock, Duration >&) NOEXCEPT;
162 template<
typename Duration >
163 static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
164 from_sys(
const std::chrono::time_point< std::chrono::system_clock, Duration >&) NOEXCEPT;
172 template<
typename Duration >
173 static std::chrono::time_point< date::local_t, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
174 to_local(
const std::chrono::time_point< hops_clock, Duration >&) NOEXCEPT;
182 template<
typename Duration >
183 static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type >
184 from_local(
const std::chrono::time_point< date::local_t, Duration >&) NOEXCEPT;
329 using namespace std::chrono;
335 auto days_since_tai_epoch = j2000_day - tai_epoch_day;
336 auto tod = hours{11} + minutes{59} + seconds{27} + milliseconds{816};
337 hops_tz::tai_time< nanoseconds > j2000_tai_epoch{duration_cast< nanoseconds >(days_since_tai_epoch) +
338 duration_cast< nanoseconds >(tod)};
339 return time_point_cast< nanoseconds >(hops_tz::tai_clock::to_utc(j2000_tai_epoch));
352 auto t_start_utc =
to_utc(t_start);
353 auto t_end_utc =
to_utc(t_end);
356 int delta = lp_info1.elapsed.count() - lp_info0.elapsed.count();
357 return std::chrono::seconds(delta);
363 static date::days day_of_year(date::sys_days sd)
365 using namespace date;
366 auto y = date::year_month_day{sd}.
year();
367 return sd - date::sys_days{y / jan / 0};
370 static date::sys_days get_year_month_day(
date::year y, date::days ord_day)
372 using namespace date;
373 return date::sys_days{y / jan / 0} + ord_day;
385 static vex_date extract_vex_date(
const std::string& timestamp);
387 static std::string vex_date_to_iso8601_string(vex_date vdate);
389 static vex_date vex_date_from_legacy(
const legacy_hops_date& legacy_date);
391 static std::string remove_trailing_zeros(std::string
value)
393 std::size_t nzeros_on_end = 0;
394 for(
auto rit =
value.rbegin(); rit !=
value.rend(); rit++)
402 std::size_t useful_length =
value.size() - nzeros_on_end;
404 for(std::size_t i = 0; i < useful_length; i++)
406 ret_val.push_back(
value[i]);
415 template<
class Duration >
using hops_time = std::chrono::time_point< hops_clock, Duration >;
423 template<
class Duration >
424 inline hops_tz::utc_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type >
428 using CD =
typename std::common_type< Duration, std::chrono::nanoseconds >::type;
429 hops_tz::utc_time< std::chrono::nanoseconds > hops_epoch_start =
get_hops_epoch_utc();
430 return hops_tz::utc_time< CD >(
t.time_since_epoch() + hops_epoch_start.time_since_epoch());
439 template<
class Duration >
443 using CD =
typename std::common_type< Duration, std::chrono::nanoseconds >::type;
444 hops_tz::utc_time< std::chrono::nanoseconds > hops_epoch_start =
get_hops_epoch_utc();
445 return hops_time< CD >(
t.time_since_epoch() - hops_epoch_start.time_since_epoch());
454 template<
class Duration >
455 inline hops_tz::tai_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type >
458 return hops_tz::tai_clock::from_utc(
to_utc(
t));
467 template<
class Duration >
471 return from_utc(hops_tz::tai_clock::to_utc(
t));
480 template<
class Duration >
481 inline hops_tz::gps_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type >
484 return hops_tz::gps_clock::from_utc(
to_utc(
t));
493 template<
class Duration >
497 return from_utc(hops_tz::gps_clock::to_utc(
t));
506 template<
class Duration >
507 inline date::sys_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type >
510 return hops_tz::utc_clock::to_sys(
to_utc(
t));
519 template<
class Duration >
523 return from_utc(hops_tz::utc_clock::from_sys(
t));
533 return from_utc(hops_tz::utc_clock::now());
542 template<
class Duration >
543 inline date::local_time< typename std::common_type< Duration, std::chrono::nanoseconds >::type >
546 using CD =
typename std::common_type< Duration, std::chrono::nanoseconds >::type;
547 hops_tz::utc_time< CD > hops_epoch_start = std::chrono::time_point_cast< CD >(
get_hops_epoch_utc());
548 hops_tz::utc_time< CD > ut_time{
t.time_since_epoch() +
549 std::chrono::time_point_cast< Duration >(hops_epoch_start).time_since_epoch()};
550 return hops_tz::utc_clock::to_local(ut_time);
559 template<
class Duration >
563 using CD =
typename std::common_type< Duration, std::chrono::nanoseconds >::type;
564 hops_tz::utc_time< CD > t2 = hops_tz::utc_clock::from_local(
t);
565 hops_tz::utc_time< CD > hops_epoch_start = std::chrono::time_point_cast< CD >(
get_hops_epoch_utc());
567 std::chrono::time_point_cast< Duration >(hops_epoch_start).time_since_epoch()};
581 template<
class CharT,
class Traits,
class Duration >
582 std::basic_ostream< CharT, Traits >&
to_stream(std::basic_ostream< CharT, Traits >& os,
const CharT* fmt,
585 const std::string abbrev(
"HOPS");
586 CONSTDATA std::chrono::seconds offset{0};
603 template<
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator< CharT > >
604 std::basic_istream< CharT, Traits >&
606 std::basic_string< CharT, Traits, Alloc >* abbrev =
nullptr, std::chrono::minutes* offset =
nullptr)
608 date::local_time< Duration > lp;
615 template<
class CharT,
class Traits,
class Duration >
616 std::basic_ostream< CharT, Traits >&
operator<<(std::basic_ostream< CharT, Traits >& os,
const hops_time< Duration >&
t)
618 const CharT fmt[] = {
'%',
'F',
'T',
'%',
'T',
'Z', CharT{}};
630 using namespace date;
631 using namespace std::chrono;
633 std::istringstream ss(timestamp);
634 std::istream tmp_stream(ss.rdbuf());
648 std::stringstream ss;
661 using namespace date;
662 using namespace std::chrono;
666 std::vector< std::string >
tokens;
671 std::string hops_prefix =
tokens[0];
672 std::string unit =
tokens[1];
673 std::string nanosecond_count =
tokens[2];
676 std::stringstream ss;
677 ss << nanosecond_count;
680 return time_point(std::chrono::nanoseconds(ns));
683 msg_error(
"utility",
"hops timestamp string not understood or supported, returning epoch start. " << eom);
684 return time_point(std::chrono::nanoseconds(0));
695 std::stringstream ss;
700 ss << tp.time_since_epoch().count();
706 vex_date vdate = vex_date_from_legacy(ldate);
707 std::string vex_as_iso8601 = vex_date_to_iso8601_string(vdate);
713 using namespace date;
714 using namespace std::chrono;
718 auto dp = date::sys_days(floor< date::days >(sys_tp));
721 date::year_month_day ymd{dp};
722 auto year = ymd.year();
725 auto ordinal_day = day_of_year(dp);
728 date::hh_mm_ss< std::chrono::nanoseconds > time{floor< std::chrono::nanoseconds >(sys_tp - dp)};
729 auto hours = time.hours();
730 auto mins = time.minutes();
731 auto secs = time.seconds();
732 auto nanos = time.subseconds();
735 ldate.
year = (int)year;
736 ldate.
day = ordinal_day.count();
737 ldate.
hour = hours.count();
738 ldate.
minute = mins.count();
748 int integer_days = (int)floating_point_days;
749 double fractional_day = floating_point_days - integer_days;
750 int integer_hours = (int)24 * fractional_day;
751 double fractional_hour = 24 * fractional_day - integer_hours;
752 int integer_minutes = (int)60 * fractional_hour;
753 double fractional_seconds = (60 * fractional_hour - integer_minutes) * 60;
757 ldate.
year = (short)year;
758 ldate.
day = (short)integer_days + 1;
759 ldate.
hour = (short)integer_hours;
760 ldate.
minute = (short)integer_minutes;
761 ldate.
second = fractional_seconds;
768 using namespace date;
769 using namespace std::chrono;
773 auto dp = date::sys_days(floor< date::days >(sys_tp));
776 date::year_month_day ymd{dp};
777 auto year_value = ymd.year();
779 auto ordinal_day = day_of_year(dp);
780 int integer_days = ordinal_day.count() - 1;
782 date::hh_mm_ss< std::chrono::nanoseconds > time{floor< std::chrono::nanoseconds >(sys_tp - dp)};
783 int ihours = time.hours().count();
784 int imins = time.minutes().count();
785 int isecs = time.seconds().count();
786 int inanos = time.subseconds().count();
789 floating_point_days = integer_days + frac_day;
790 year =
static_cast<int>(year_value);
795 double delta = (mjd - epoch_offset);
797 std::chrono::duration< double > duration_seconds(delta);
799 auto mjd_epoch_utc =
to_utc(mjd_epoch);
800 auto utc_time_point = mjd_epoch_utc + std::chrono::duration_cast< std::chrono::nanoseconds >(duration_seconds);
801 auto hops_time_point =
from_utc(utc_time_point);
802 return hops_time_point;
807 auto mjd_epoch_utc =
to_utc(mjd_epoch);
810 double delta = (tp_utc - mjd_epoch_utc).count();
813 delta += epoch_offset;
819 vex_date vdate = hops_clock::extract_vex_date(timestamp);
821 std::string vex_as_iso8601 = vex_date_to_iso8601_string(vdate);
827 using namespace date;
828 using namespace std::chrono;
832 auto dp = date::sys_days(floor< date::days >(sys_tp));
835 date::year_month_day ymd{dp};
836 auto year = ymd.year();
841 auto ordinal_day = day_of_year(dp);
844 date::hh_mm_ss< std::chrono::nanoseconds > time{floor< std::chrono::nanoseconds >(sys_tp - dp)};
845 auto hours = time.hours();
846 auto mins = time.minutes();
847 auto secs = time.seconds();
848 auto nanos = time.subseconds();
853 std::stringstream ss;
856 ss << std::setfill(
'0') << std::setw(3) << ordinal_day.count();
858 ss << std::setfill(
'0') << std::setw(2) << hours.count();
860 ss << std::setfill(
'0') << std::setw(2) << mins.count();
862 ss << std::setfill(
'0') << std::setw(2) << secs.count();
864 if(!truncate_to_nearest_second)
866 std::stringstream nss;
867 nss << std::setfill(
'0') << std::setw(9) << nanos.count();
868 std::string snano_sec;
870 std::string trimmed_nanosec = remove_trailing_zeros(snano_sec);
871 if(trimmed_nanosec.size() != 0)
874 ss << trimmed_nanosec;
884 using namespace date;
885 using namespace std::chrono;
889 auto dp = date::sys_days(floor< date::days >(sys_tp));
892 date::year_month_day ymd{dp};
893 auto year = ymd.year();
894 auto month = ymd.month();
895 auto day = ymd.day();
898 int iyear =
static_cast< int >(year);
899 unsigned int imonth =
static_cast< unsigned int >(month);
900 int epoch = (iyear % 100) * 2;
920 std::stringstream ss;
923 ss << std::setfill(
'0') << std::setw(2) << imonth;
925 ss << std::setfill('0') << std::setw(2) << static_cast< unsigned int >(day);
927 ss << std::setfill(
'0') << std::setw(2) << hours;
929 ss << std::setfill(
'0') << std::setw(2) << minutes;
931 ss << std::setfill(
'0') << std::setw(2) << integer_sec;
933 std::string epoch_iso8601 = ss.str();
935 int secs = std::chrono::duration_cast< std::chrono::seconds >(tp - epoch_tp).count();
943 using namespace date;
944 using namespace std::chrono;
946 int start_year = 2000;
947 int n_years = std::floor(vdif_epoch / 2);
948 int iyear = start_year + n_years;
950 unsigned int imonth = 1;
951 if(vdif_epoch % 2 == 1)
955 unsigned int iday = 1;
962 std::stringstream ss;
965 ss << std::setfill(
'0') << std::setw(2) << imonth;
967 ss << std::setfill(
'0') << std::setw(2) << iday;
969 ss << std::setfill(
'0') << std::setw(2) << hours;
971 ss << std::setfill(
'0') << std::setw(2) << minutes;
973 ss << std::setfill(
'0') << std::setw(2) << integer_sec;
975 std::string epoch_iso8601 = ss.str();
976 std::cout <<
"epoch = " << epoch_iso8601 << std::endl;
978 auto tp = epoch_tp + std::chrono::seconds(vdif_seconds);
982 inline hops_clock::vex_date hops_clock::extract_vex_date(
const std::string& timestamp)
985 if(timestamp.size() == 0)
987 msg_error(
"utilities",
"cannot extract vex date from empty string." << eom);
991 MHO_Tokenizer tokenizer;
992 std::vector< std::string >
tokens;
993 std::stringstream ss;
995 std::string syear, sord_day, shour, smin, ssec;
997 tokenizer.SetDelimiter(std::string(
"y"));
998 tokenizer.SetString(×tamp);
999 tokenizer.GetTokens(&
tokens);
1006 tokenizer.SetDelimiter(std::string(
"d"));
1007 tokenizer.SetString(&rest);
1008 tokenizer.GetTokens(&
tokens);
1011 ss.str(std::string());
1014 ss >> vdate.day_of_year;
1017 tokenizer.SetDelimiter(std::string(
"h"));
1018 tokenizer.SetString(&rest);
1019 tokenizer.GetTokens(&
tokens);
1022 ss.str(std::string());
1028 tokenizer.SetDelimiter(std::string(
"m"));
1029 tokenizer.SetString(&rest);
1030 tokenizer.GetTokens(&
tokens);
1033 ss.str(std::string());
1036 ss >> vdate.minutes;
1039 tokenizer.SetDelimiter(std::string(
"s"));
1040 tokenizer.SetString(&rest);
1041 tokenizer.GetTokens(&
tokens);
1044 ss.str(std::string());
1046 ss << std::setprecision(15) << ssec;
1047 ss >> vdate.seconds;
1052 inline std::string hops_clock::vex_date_to_iso8601_string(hops_clock::vex_date vdate)
1054 using namespace date;
1055 using namespace std::chrono;
1057 std::stringstream ss;
1062 date::days ord_day(vdate.day_of_year);
1063 date::sys_days ymd = get_year_month_day(y, ord_day);
1066 auto month = date::year_month_day{ymd}.month();
1067 auto mday = date::year_month_day{ymd}.day();
1068 ss << std::setfill(
'0') << std::setw(2) << (unsigned)month;
1070 ss << std::setfill(
'0') << std::setw(2) << (unsigned)mday;
1073 ss << std::setfill(
'0') << std::setw(2) << vdate.hours;
1075 ss << std::setfill(
'0') << std::setw(2) << vdate.minutes;
1081 double frac = modf(vdate.seconds, &intpart);
1082 int integer_sec = intpart;
1084 ss << std::setfill(
'0') << std::setw(2) << integer_sec;
1091 std::stringstream nss;
1092 nss << std::setfill(
'0') << std::setw(9) << integer_nanosec;
1093 std::string nanoseconds_value = nss.str();
1094 std::string trimmed_int_nanosec = remove_trailing_zeros(nanoseconds_value);
1095 if(trimmed_int_nanosec.size() != 0)
1098 ss << trimmed_int_nanosec;
1104 inline hops_clock::vex_date hops_clock::vex_date_from_legacy(
const legacy_hops_date& legacy_date)
1106 hops_clock::vex_date vdate;
1107 vdate.year = legacy_date.year;
1108 vdate.day_of_year = legacy_date.day;
1109 vdate.hours = legacy_date.hour;
1110 vdate.minutes = legacy_date.minute;
1111 vdate.seconds = legacy_date.second;
1120 std::size_t pos = 0;
1123 const int digit_counts[4] = {4, 3, 2, 2};
1124 const char separators[4] = {
'y',
'd',
'h',
'm'};
1129 for(
int i = 0; i < digit_counts[
field]; i++)
1131 if(pos >= s.size() || !std::isdigit(
static_cast<unsigned char>(s[pos])))
1138 if( pos >= s.size() || s[pos] != separators[
field])
1146 for(
int i = 0; i < 2; ++i)
1148 if (pos >= s.size() || !std::isdigit(
static_cast<unsigned char>(s[pos])))
1156 if (pos < s.size() && s[pos] ==
'.')
1159 if (pos >= s.size() || !std::isdigit(
static_cast<unsigned char>(s[pos])))
1164 while (pos < s.size() && std::isdigit(
static_cast<unsigned char>(s[pos])))
1171 if (pos >= s.size() || s[pos] !=
's'){
return false;}
1175 return pos == s.size();
#define ISO8601_UTC_FORMAT
Definition: MHO_Clock.hh:32
#define MINUTE_TO_SEC
Definition: MHO_Clock.hh:39
#define SEC_TO_NANOSEC
Definition: MHO_Clock.hh:37
#define HOPS_TIMESTAMP_PREFIX
Definition: MHO_Clock.hh:33
#define HOPS_TIME_DELIM
Definition: MHO_Clock.hh:34
#define NANOSEC_TO_SEC
Definition: MHO_Clock.hh:36
#define HOPS_TIME_UNIT
Definition: MHO_Clock.hh:35
#define JD_TO_SEC
Definition: MHO_Clock.hh:38
#define HOUR_TO_SEC
Definition: MHO_Clock.hh:40
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:246
Class MHO_Tokenizer.
Definition: MHO_Tokenizer.hh:24
void SetString(const std::string *aString)
Definition: MHO_Tokenizer.cc:65
void GetTokens(std::vector< std::string > *tokens)
Definition: MHO_Tokenizer.cc:75
void SetDelimiter(const std::string &aDelim)
Definition: MHO_Tokenizer.cc:70
a clock for hops-time stamps, measures time in (UTC) nanoseconds since J2000 epoch....
Definition: MHO_Clock.hh:66
static std::chrono::time_point< hops_tz::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.
static time_point get_hops_epoch()
returns the hops_clock epoch as a hops_clock time_point
Definition: MHO_Clock.hh:345
duration::period period
Definition: MHO_Clock.hh:70
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.
Definition: MHO_Clock.hh:882
static time_point now()
Returns current time as a time_point using hops_clock's epoch.
Definition: MHO_Clock.hh:531
std::chrono::time_point< hops_clock, std::chrono::nanoseconds > time_point
Definition: MHO_Clock.hh:71
static std::chrono::time_point< hops_tz::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).
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.
static bool is_vex_timestamp(const std::string &s)
Definition: MHO_Clock.hh:1118
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.
static std::string to_iso8601_format(const time_point &tp)
Converts a time_point to ISO8601 formatted string.
Definition: MHO_Clock.hh:646
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,...
Definition: MHO_Clock.hh:746
std::chrono::nanoseconds duration
Definition: MHO_Clock.hh:68
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.
static time_point from_hops_format(const std::string ×tamp)
Converts a timestamp string in HOPS format to a time_point object.
Definition: MHO_Clock.hh:659
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_gps(const std::chrono::time_point< hops_tz::gps_clock, Duration > &) NOEXCEPT
Converts GPS time to Hops clock time.
static time_point from_iso8601_format(const std::string ×tamp)
Converts an ISO8601 formatted timestamp string to a hops_clock time_point object.
Definition: MHO_Clock.hh:628
duration::rep rep
Definition: MHO_Clock.hh:69
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_utc(const std::chrono::time_point< hops_tz::utc_clock, Duration > &) NOEXCEPT
Converts UTC time point to hops_clock time point.
static double to_mjd(const time_point &mjd_epoch, double epoch_offset, const time_point &tp)
Converts a hops_clock time_point to a Modified Julian date (floating point day) timestamp,...
Definition: MHO_Clock.hh:805
static time_point from_vdif_format(int &vdif_epoch, int &vdif_seconds)
Converts a VDIF (epoch, second) timestamp to a hops_clock time_point.
Definition: MHO_Clock.hh:941
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)
Definition: MHO_Clock.hh:825
static std::chrono::time_point< hops_tz::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.
static hops_tz::utc_time< std::chrono::nanoseconds > get_hops_epoch_utc()
returns the hops_clock epoch as a utc_time time_point
Definition: MHO_Clock.hh:327
static std::string to_hops_format(const time_point &tp)
Converts a time_point to HOPS format string.
Definition: MHO_Clock.hh:693
static time_point from_vex_format(const std::string ×tamp)
Converts a VEX-style formatted string (e.g. 2019y106d18h30m15s) to a hops_clock time_point.
Definition: MHO_Clock.hh:817
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)
Definition: MHO_Clock.hh:350
static time_point from_mjd(const time_point &mjd_epoch, double epoch_offset, double mjd)
Converts a Modified Julian date (floating point epoch and day) timestamp to a hops_clock time_point.
Definition: MHO_Clock.hh:793
static const bool is_steady
Definition: MHO_Clock.hh:72
static std::chrono::time_point< hops_clock, typename std::common_type< Duration, std::chrono::nanoseconds >::type > from_tai(const std::chrono::time_point< hops_tz::tai_clock, Duration > &) NOEXCEPT
Converts a TAI time point to UTC and returns the corresponding Hops clock time.
static legacy_hops_date to_legacy_hops_date(const time_point &tp)
Converts a hops_clock time_point to a legacy hops data struct.
Definition: MHO_Clock.hh:711
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 fl...
Definition: MHO_Clock.hh:766
static time_point from_legacy_hops_date(legacy_hops_date &ldate)
Converts a legacy hops data struct to a hops_clock time_point.
Definition: MHO_Clock.hh:704
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.
char * field(char *, char *, int)
Definition: fourmer.c:236
Self-contained (link-free) reimplementation of the small slice of the date library's tz facilities th...
short day
Definition: mk4_typedefs.h:17
short year
Definition: mk4_typedefs.h:16
Definition: mk4_typedefs.h:15
t
Definition: picking_aedit.py:14
Definition: MHO_AdhocFlagging.hh:18
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const hops_time< Duration > &t)
Definition: MHO_Clock.hh:616
short hour
Definition: legacy_hops_date.hh:20
std::basic_istream< CharT, Traits > & from_stream(std::basic_istream< CharT, Traits > &is, const CharT *fmt, hops_time< Duration > &tp, std::basic_string< CharT, Traits, Alloc > *abbrev=nullptr, std::chrono::minutes *offset=nullptr)
Reads time and abbreviation from stream using given format, updates hops_time if successful.
Definition: MHO_Clock.hh:605
leap_second_info get_leap_second_info(const utc_time< Duration > &ut)
Leap-second lookup for a utc_time, matching date::get_leap_second_info.
Definition: hops_leap_seconds.hh:171
short minute
Definition: legacy_hops_date.hh:21
short day
Definition: legacy_hops_date.hh:19
std::chrono::time_point< hops_clock, Duration > hops_time
Class hops_time.
Definition: MHO_Clock.hh:415
std::basic_ostream< CharT, Traits > & to_stream(std::basic_ostream< CharT, Traits > &os, const CharT *fmt, const hops_time< Duration > &t)
Converts hops_time to stream format using given fmt and outputs to os.
Definition: MHO_Clock.hh:582
double second
Definition: legacy_hops_date.hh:22
short year
Definition: legacy_hops_date.hh:18
A struct to avoid name collisions between the mk4utils 'data' struct and the 'date' header library.
Definition: legacy_hops_date.hh:17
struct token_struct * tokens
Definition: parse_control_file.c:26