1 #if !defined(_PSYTIME_H_) 15 #define USEC_YEAR_0_TO_1970 62167305600000000L 16 #define SECS_PER_YEAR 31536000 17 #define SECS_PER_MONTH 2629744 18 #define SECS_PER_WEEK 604800 19 #define SECS_PER_DAY 86400 20 #define SECS_PER_HOUR 3600 21 #define SECS_PER_MIN 60 22 #define TIME_YEAR_1970 62167305600000000L 24 #define SECOND_MS 1000 25 #define MINUTE_MS SECS_PER_MIN * 1000 26 #define HOUR_MS SECS_PER_HOUR * 1000 27 #define DAY_MS SECS_PER_DAY * 1000 28 #define WEEK_MS SECS_PER_WEEK * 1000 29 #define MONTH_MS (uint64)SECS_PER_MONTH * 1000 30 #define YEAR_MS (uint64)SECS_PER_YEAR * 1000 32 #define SECOND_US (uint64)1000000 33 #define MINUTE_US (uint64)SECS_PER_MIN * 1000000 34 #define HOUR_US (uint64)SECS_PER_HOUR * 1000000 35 #define DAY_US (uint64)SECS_PER_DAY * 1000000 36 #define WEEK_US (uint64)SECS_PER_WEEK * 1000000 37 #define MONTH_US (uint64)SECS_PER_MONTH * 1000000 38 #define YEAR_US (uint64)SECS_PER_YEAR * 1000000 40 #define PSYSECOND SECOND_US 41 #define PSYMINUTE MINUTE_US 42 #define PSYHOUR HOUR_US 44 #define PSYWEEK WEEK_US 45 #define PSYMONTH MONTH_US 46 #define PSYYEAR YEAR_US 48 static char PsyDays[][5] = {
"None",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"};
49 static char PsyDaysFull[][10] = {
"None",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"};
50 static char PsyMonths[][5] = {
"None",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
51 static char PsyMonthsFull[][10] = {
"None",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"};
75 uint64 SyncToHardwareClock();
76 bool SetCurrentNetSyncDif(int64 netTimeDif);
77 bool SetCurrentTimeSyncData(uint64 tmc, int64 netTimeAdjust);
78 bool GetCurrentTimeSyncData(uint64& tmc, int64& netTimeAdjust);
84 #define TMC_SYNC_INTERVAL 60000000 // 1 minute 86 static uint64 CurrentTMC = 0;
87 static uint8 CurrentTMCMode = TMC_MASTER;
88 static uint64 LastTMCSync = 0;
89 static int64 NetTimeAdjust = 0;
92 uint64 EstNextTMCWrap();
95 int64 GetTimeAge(uint64 t);
96 int32 GetTimeAgeMS(uint64 t);
97 uint64 GetTimeFromString(
const char* str);
98 uint32 GetHTTPTime(uint64 time,
char* buffer, uint32 size);
101 uint32 GetTimeOffsetGMT();
103 struct PsyDateAndTime GetDateAndTime(uint64 t, bool local =
true);
109 char* PrintTime(uint64 t,
bool local =
true,
bool us =
true,
bool ms =
true);
110 char* PrintTimeOnly(uint64 t,
bool local =
true,
bool us =
true,
bool ms =
true);
111 char* PrintTimeDif(uint64 t,
bool us =
true,
bool ms =
true);
112 char* PrintDate(uint64 t,
bool local =
true);
113 char* PrintDateSortable(uint64 t,
bool local =
true);
114 char* PrintDateSortableDelimiter(uint64 t,
const char* del,
bool local =
true);
116 char* PrintTimeSortable(uint64 t,
bool local);
117 char* PrintTimeSortableMillisec(uint64 t,
bool local);
118 char* PrintTimeSortableMicrosec(uint64 t,
bool local);
120 std::string PrintTimeNowString(
bool local =
true,
bool us =
true,
bool ms =
true);
121 std::string PrintTimeString(uint64 t,
bool local =
true,
bool us =
true,
bool ms =
true);
122 std::string PrintTimeOnlyString(uint64 t,
bool local =
true,
bool us =
true,
bool ms =
true);
123 std::string PrintTimeDifString(uint64 t,
bool us =
true,
bool ms =
true);
124 std::string PrintDateString(uint64 t,
bool local =
true);
125 std::string PrintDateStringSortable(uint64 t,
bool local =
true);
126 std::string PrintDateStringSortableDelimiter(uint64 t,
const char* del,
bool local =
true);
128 std::string PrintTimeSortableString(uint64 t,
bool local =
true);
129 std::string PrintTimeSortableMillisecString(uint64 t,
bool local =
true);
130 std::string PrintTimeSortableMicrosecString(uint64 t,
bool local =
true);
132 uint64 FTime2PsyTime(uint64 t);
134 bool PsyTime_UnitTest();