Evo C++ Library v0.5.1
systime.h
Go to the documentation of this file.
1 // Evo C++ Library
2 /* Copyright 2019 Justin Crowell
3 Distributed under the BSD 2-Clause License -- see included file LICENSE.txt for details.
4 */
6 
7 #pragma once
8 #ifndef INCL_evo_systime_h
9 #define INCL_evo_systime_h
10 
11 #include "sys.h"
12 
13 #if !defined(_WIN32) && !(defined(_POSIX_TIMERS) && defined(CLOCK_PROCESS_CPUTIME_ID))
14  #include <sys/resource.h>
15 #endif
16 
17 namespace evo {
20 
22 
28 #if defined(_WIN32)
29  // Windows
30  typedef SYSTEMTIME Fields;
31  SYSTEMTIME ts;
32 
33  void set_utc() {
34  ::GetSystemTime(&ts);
35  }
36 
37  int64 get_unix_timestamp() const {
38  const ulongl NSEC100_PER_SEC = 10000000;
39  const ulongl UNIX_OFFSET = 11644473600ULL; // seconds between 1601 (Windows epoch) and 1970 (Unix epoch)
40  FILETIME ft;
41  if (::SystemTimeToFileTime(&ts, &ft) == 0)
42  return 0;
43  const ulongl ft_nsec100 = ((ulongl)ft.dwHighDateTime << 32) | (ulongl)ft.dwLowDateTime;
44  const int64 sec = (int64)(ft_nsec100 / NSEC100_PER_SEC);
45  if (sec < UNIX_OFFSET)
46  return 0;
47  return sec - UNIX_OFFSET;
48  }
49 
50  int get_msec() const {
51  return ts.wMilliseconds;
52  }
53 
54  long get_nsec() const {
55  const long NSEC_PER_MSEC = 1000000L;
56  return (long)ts.wMilliseconds / NSEC_PER_MSEC;
57  }
58 
59  template<class DT>
60  void convert_utc_dt(DT& dt) const {
61  dt.date.year = ts.wYear;
62  dt.date.month = ts.wMonth;
63  dt.date.day = ts.wDay;
64  dt.time.hour = ts.wHour;
65  dt.time.minute = ts.wMinute;
66  dt.time.second = ts.wSecond;
67  dt.time.msecond = ts.wMilliseconds;
68  dt.tz.minutes = 0;
69  }
70 
71  template<class DT>
72  void convert_local_dt(DT& dt) const {
73  TIME_ZONE_INFORMATION info;
74  TIME_ZONE_INFORMATION* p_info;
75  if (::GetTimeZoneInformation(&info) == TIME_ZONE_ID_INVALID) {
76  p_info = NULL;
77  dt.tz.minutes = 0;
78  } else {
79  p_info = &info;
80  dt.tz.minutes = (int)-info.Bias;
81  }
82 
83  SYSTEMTIME local;
84  BOOL result = ::SystemTimeToTzSpecificLocalTime(p_info, &ts, &local);
85  assert( result != 0 );
86  if (result != 0) {
87  dt.date.year = local.wYear;
88  dt.date.month = local.wMonth;
89  dt.date.day = local.wDay;
90  dt.time.hour = local.wHour;
91  dt.time.minute = local.wMinute;
92  dt.time.second = local.wSecond;
93  dt.time.msecond = local.wMilliseconds;
94  } else
95  convert_utc_dt(dt);
96  }
97 
98  template<class DT>
99  void convert_local_dt_notz(DT& dt) const {
100  SYSTEMTIME local;
101  BOOL result = ::SystemTimeToTzSpecificLocalTime(NULL, &ts, &local);
102  assert( result != 0 );
103  if (result != 0) {
104  dt.date.year = local.wYear;
105  dt.date.month = local.wMonth;
106  dt.date.day = local.wDay;
107  dt.time.hour = local.wHour;
108  dt.time.minute = local.wMinute;
109  dt.time.second = local.wSecond;
110  dt.time.msecond = local.wMilliseconds;
111  dt.tz.set();
112  } else
113  convert_utc_dt(dt);
114  }
115 
116 #else
117  // Linux/Unix
118 #if defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME) && !defined(EVO_USE_GETTIMEOFDAY)
119  typedef struct timespec Fields;
120  struct timespec ts;
121 
122  void set_utc() {
123  #if defined(CLOCK_REALTIME_COARSE)
124  ::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
125  #else
126  ::clock_gettime(CLOCK_REALTIME, &ts);
127  #endif
128  assert( ts.tv_sec > 0 );
129  }
130 
131  int64 get_unix_timestamp() const {
132  return (int64)ts.tv_sec;
133  }
134 
135  int get_msec() const {
136  const long NSEC_PER_MSEC = 1000000L;
137  return (int)(ts.tv_nsec / NSEC_PER_MSEC);
138  }
139 
140  long get_nsec() const {
141  return ts.tv_nsec;
142  }
143 
144 #else
145  typedef struct timeval Fields;
146  struct timeval ts;
147 
149  void set_utc() {
150  ::gettimeofday(&ts, NULL);
151  assert( ts.tv_sec > 0 );
152  }
153 
159  int64 get_unix_timestamp() const {
160  return (int64)ts.tv_sec;
161  }
162 
166  int get_msec() const {
167  const long USEC_PER_MSEC = 1000L;
168  return (int)((long)ts.tv_usec / USEC_PER_MSEC);
169  }
170 
174  long get_nsec() const {
175  const long NSEC_PER_USEC = 1000L;
176  return (long)ts.tv_usec * NSEC_PER_USEC;
177  }
178 
179 #endif
180  static const int SEC_PER_MIN = 60;
181 
186  template<class DT>
187  void convert_utc_dt(DT& dt) const {
188  struct tm tm;
189  ::gmtime_r(&ts.tv_sec, &tm);
190  dt.date.year = 1900 + tm.tm_year;
191  dt.date.month = tm.tm_mon + 1;
192  dt.date.day = tm.tm_mday;
193  dt.time.hour = tm.tm_hour;
194  dt.time.minute = tm.tm_min;
195  dt.time.second = tm.tm_sec;
196  dt.time.msecond = get_msec();
197  }
198 
203  template<class DT>
204  void convert_local_dt(DT& dt) const {
205  struct tm tm;
206  ::tzset();
207  ::localtime_r(&ts.tv_sec, &tm);
208  #if defined(__FreeBSD__)
209  dt.tz.minutes = (tm.tm_gmtoff / SEC_PER_MIN);
210  #else
211  dt.tz.minutes = -(::timezone / SEC_PER_MIN);
212  #endif
213  dt.date.year = 1900 + tm.tm_year;
214  dt.date.month = tm.tm_mon + 1;
215  dt.date.day = tm.tm_mday;
216  dt.time.hour = tm.tm_hour;
217  dt.time.minute = tm.tm_min;
218  dt.time.second = tm.tm_sec;
219  dt.time.msecond = get_msec();
220  }
221 
226  template<class DT>
227  void convert_local_dt_notz(DT& dt) const {
228  struct tm tm;
229  ::localtime_r(&ts.tv_sec, &tm);
230  dt.date.year = 1900 + tm.tm_year;
231  dt.date.month = tm.tm_mon + 1;
232  dt.date.day = tm.tm_mday;
233  dt.time.hour = tm.tm_hour;
234  dt.time.minute = tm.tm_min;
235  dt.time.second = tm.tm_sec;
236  dt.time.msecond = get_msec();
237  }
238 #endif
239 
244  }
245 
250  { ::memcpy(this, &src, sizeof(SysNativeTimeStamp)); }
251 
257  { ::memcpy(this, &src, sizeof(SysNativeTimeStamp)); return *this; }
258 
260  void set()
261  { ::memset(&ts, 0, sizeof(Fields)); }
262 };
263 
265 
269 struct SysTimestamp {
270  static const ulong NSEC_PER_SEC = 1000000000UL;
271  static const ulong USEC_PER_SEC = 1000000UL;
272  static const ulong MSEC_PER_SEC = 1000;
273  static const ulong NSEC_PER_MSEC = 1000000UL;
274  static const ulong NSEC_PER_USEC = 1000;
275  static const int SEC_PER_MIN = 60;
276 
277 #if defined(_WIN32)
278  static const int EPOCH_YEAR = 1601;
279 #else
280  static const int EPOCH_YEAR = 1970;
281 #endif
282 
283  ulongl sec;
284  ulong nsec;
285 
287  SysTimestamp() : sec(0), nsec(0) {
288  }
289 
293  SysTimestamp(const SysTimestamp& src) : sec(src.sec), nsec(src.nsec) {
294  }
295 
301  sec = src.sec;
302  nsec = src.nsec;
303  return *this;
304  }
305 
307  void clear() {
308  sec = 0;
309  nsec = 0;
310  }
311 
312 #if defined(_WIN32)
313  void set_win32_ft(const FILETIME& ft) {
314  const ulongl NSEC100_PER_SEC = 10000000;
315  const ulong NSEC_PER_NSEC100 = 100;
316 
317  const ulongl ft_nsec100 = ((ulongl)ft.dwHighDateTime << 32) | (ulongl)ft.dwLowDateTime;
318  sec = ft_nsec100 / NSEC100_PER_SEC;
319  nsec = (ulong)(ft_nsec100 - (sec * NSEC100_PER_SEC)) * NSEC_PER_NSEC100;
320  }
321 
322  void add_win32_ft(const FILETIME& ft) {
323  const ulongl NSEC100_PER_SEC = 10000000;
324  const ulong NSEC_PER_NSEC100 = 100;
325  {
326  const ulongl ft_nsec100 = ((ulongl)ft.dwHighDateTime << 32) | (ulongl)ft.dwLowDateTime;
327  sec += ft_nsec100 / NSEC100_PER_SEC;
328  nsec += (ulong)(ft_nsec100 - (sec * NSEC100_PER_SEC)) * NSEC_PER_NSEC100;
329  }
330  const ulong add_sec = (nsec / NSEC_PER_SEC);
331  sec += add_sec;
332  nsec -= (add_sec * NSEC_PER_SEC);
333  }
334 #endif
335 
342  void set(const SysNativeTimeStamp& src) {
343  #if defined(_WIN32)
344  FILETIME ft;
345  ::SystemTimeToFileTime(&src.ts, &ft);
346  set_win32_ft(ft);
347  #else
348  sec = (ulongl)src.ts.tv_sec;
349  nsec = (ulong)src.get_nsec();
350  #endif
351  }
352 
359  #if defined(_WIN32)
360  FILETIME ft;
361  SYSTEMTIME stm;
362  ::GetSystemTime(&stm);
363  ::SystemTimeToFileTime(&stm, &ft);
364  set_win32_ft(ft);
365  #elif defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME) && !defined(EVO_USE_GETTIMEOFDAY)
366  struct timespec ts;
367  #if defined(CLOCK_REALTIME_COARSE)
368  ::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
369  #else
370  ::clock_gettime(CLOCK_REALTIME, &ts);
371  #endif
372  assert( ts.tv_sec > 0 );
373  assert( ts.tv_nsec >= 0 );
374 
375  sec = (ulongl)ts.tv_sec;
376  nsec = (ulong)ts.tv_nsec;
377  #else
378  struct timeval tv;
379  ::gettimeofday(&tv, NULL);
380  assert( tv.tv_sec > 0 );
381  assert( tv.tv_usec >= 0 );
382 
383  sec = (ulongl)tv.tv_sec;
384  nsec = (ulong)tv.tv_usec * NSEC_PER_USEC;
385  #endif
386  }
387 
392  void set_wall_timer() {
393  #if defined(_WIN32)
394  #if defined(EVO_WIN32_NO_QPC)
395  // More compatible with old hardware, subject to time adjustments (daylight savings, NTP)
396  FILETIME ft;
397  ::GetSystemTimeAsFileTime(&ft);
398  set_win32_ft(ft);
399  #else
400  // Monotonic, best for relatively modern systems
401  static const ulongl FREQ = (ulongl)qpc_get_freq();
402  LARGE_INTEGER qpc;
403  ::QueryPerformanceCounter(&qpc);
404  assert( qpc.QuadPart > 0 );
405 
406  sec = qpc.QuadPart / FREQ;
407  nsec = (ulong)( ((ulongl)qpc.QuadPart - (sec * FREQ)) * NSEC_PER_SEC / FREQ );
408  #endif
409  #elif defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME) && !defined(EVO_USE_GETTIMEOFDAY)
410  struct timespec ts;
411  #if defined(CLOCK_MONOTONIC_RAW)
412  ::clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
413  #elif defined(CLOCK_MONOTONIC)
414  ::clock_gettime(CLOCK_MONOTONIC, &ts);
415  #else
416  ::clock_gettime(CLOCK_REALTIME, &ts);
417  #endif
418  assert( ts.tv_sec > 0 );
419  assert( ts.tv_nsec >= 0 );
420 
421  sec = (ulongl)ts.tv_sec;
422  nsec = (ulong)ts.tv_nsec;
423  #else
424  struct timeval tv;
425  ::gettimeofday(&tv, NULL);
426  assert( tv.tv_sec > 0 );
427  assert( tv.tv_usec >= 0 );
428 
429  sec = (ulongl)tv.tv_sec;
430  nsec = (ulong)tv.tv_usec * NSEC_PER_USEC;
431  #endif
432  }
433 
435  void set_cpu() {
436  #if defined(_WIN32)
437  FILETIME create, exit, kernel, user;
438  ::GetProcessTimes(::GetCurrentProcess(), &create, &exit, &kernel, &user);
439  set_win32_ft(kernel);
440  add_win32_ft(user);
441  #elif defined(_POSIX_TIMERS) && defined(CLOCK_PROCESS_CPUTIME_ID)
442  struct timespec ts;
443  ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
444  assert( ts.tv_nsec >= 0 );
445 
446  sec = (ulongl)ts.tv_sec;
447  nsec = (ulong)ts.tv_nsec;
448  #else
449  struct rusage ru;
450  ::getrusage(RUSAGE_SELF, &ru);
451 
452  sec = (ulongl)ru.ru_stime.tv_sec + (ulongl)ru.ru_utime.tv_sec;
453  nsec = ((ulong)ru.ru_stime.tv_usec + (ulong)ru.ru_stime.tv_usec) * NSEC_PER_USEC;
454 
455  if (nsec >= NSEC_PER_SEC) {
456  ++sec;
457  nsec -= NSEC_PER_SEC;
458  }
459  #endif
460  }
461 
467  void add_msec(ulong new_msec) {
468  // normalize new_nsec first to avoid overflow
469  ulong new_sec = new_msec / MSEC_PER_SEC;
470  sec += new_sec;
471  nsec += (ulong)(new_msec - (new_sec * MSEC_PER_SEC)) * NSEC_PER_MSEC;
472 
473  new_sec = nsec / NSEC_PER_SEC;
474  sec += new_sec;
475  nsec -= (ulong)(new_sec * NSEC_PER_SEC);
476  }
477 
483  void add_nsec(ulongl new_nsec) {
484  // normalize new_nsec first to avoid overflow
485  ulongl new_sec = new_nsec / NSEC_PER_SEC;
486  sec += new_sec;
487  nsec += (ulong)(new_nsec - (new_sec * NSEC_PER_SEC));
488 
489  new_sec = nsec / NSEC_PER_SEC;
490  sec += new_sec;
491  nsec -= (ulong)(new_sec * NSEC_PER_SEC);
492  }
493 
498  int compare(const SysTimestamp& oth) const {
499  if (sec < oth.sec)
500  return -1;
501  else if (sec > oth.sec)
502  return 1;
503  else if (nsec < oth.nsec)
504  return -1;
505  else if (nsec > oth.nsec)
506  return 1;
507  return 0;
508  }
509 
514  ulongl diff_msec(const SysTimestamp& start) const {
515  assert( start.sec <= sec );
516  assert( start.sec < sec || start.nsec <= nsec );
517  return ((sec - start.sec) * MSEC_PER_SEC) + (nsec / NSEC_PER_MSEC) - (start.nsec / NSEC_PER_MSEC);
518  }
519 
524  ulongl diff_usec(const SysTimestamp& start) const {
525  assert( start.sec <= sec );
526  assert( start.sec < sec || start.nsec <= nsec );
527  return ((sec - start.sec) * USEC_PER_SEC) + (nsec / NSEC_PER_USEC) - (start.nsec / NSEC_PER_USEC);
528  }
529 
534  ulongl diff_nsec(const SysTimestamp& start) const {
535  assert( start.sec <= sec );
536  assert( start.sec < sec || start.nsec <= nsec );
537  return ((sec - start.sec) * NSEC_PER_SEC) + nsec - start.nsec;
538  }
539 
552  static void get_wall_datetime_fields_utc(int& year, int& month, int& day, int& hour, int& minute, int& second, int& msecond) {
553  #if defined(_WIN32)
554  SYSTEMTIME stm;
555  ::GetSystemTime(&stm);
556  year = stm.wYear;
557  month = stm.wMonth;
558  day = stm.wDay;
559  hour = stm.wHour;
560  minute = stm.wMinute;
561  second = stm.wSecond;
562  msecond = stm.wMilliseconds;
563  #else
564  struct tm tm;
565  {
567  ts.set_wall_datetime();
568  const time_t sec = (time_t)ts.sec;
569  ::gmtime_r(&sec, &tm);
570  msecond = (int)(ts.nsec / NSEC_PER_MSEC);
571  }
572  year = 1900 + tm.tm_year;
573  month = tm.tm_mon + 1;
574  day = tm.tm_mday;
575  hour = tm.tm_hour;
576  minute = tm.tm_min;
577  second = tm.tm_sec;
578  #endif
579  }
580 
593  static void get_wall_datetime_fields_local(int& year, int& month, int& day, int& hour, int& minute, int& second, int& msecond) {
594  #if defined(_WIN32)
595  SYSTEMTIME stm;
596  ::GetLocalTime(&stm);
597  year = stm.wYear;
598  month = stm.wMonth;
599  day = stm.wDay;
600  hour = stm.wHour;
601  minute = stm.wMinute;
602  second = stm.wSecond;
603  msecond = stm.wMilliseconds;
604  #else
605  struct tm tm;
606  {
608  ts.set_wall_datetime();
609  const time_t sec = (time_t)ts.sec;
610  ::localtime_r(&sec, &tm);
611  msecond = (int)(ts.nsec / NSEC_PER_MSEC);
612  }
613  year = 1900 + tm.tm_year;
614  month = tm.tm_mon + 1;
615  day = tm.tm_mday;
616  hour = tm.tm_hour;
617  minute = tm.tm_min;
618  second = tm.tm_sec;
619  #endif
620  }
621 
635  static void get_wall_datetime_fields_local(int& year, int& month, int& day, int& hour, int& minute, int& second, int& msecond, int& tz_offset) {
636  #if defined(_WIN32)
637  SYSTEMTIME stm;
638  ::GetLocalTime(&stm);
639  year = stm.wYear;
640  month = stm.wMonth;
641  day = stm.wDay;
642  hour = stm.wHour;
643  minute = stm.wMinute;
644  second = stm.wSecond;
645  msecond = stm.wMilliseconds;
646  tz_offset = tz_get_offset();
647  #else
648  struct tm tm;
649  {
651  ts.set_wall_datetime();
652  const time_t sec = (time_t)ts.sec;
653  ::tzset();
654  ::localtime_r(&sec, &tm);
655  msecond = (int)(ts.nsec / NSEC_PER_MSEC);
656  #if defined(__FreeBSD__)
657  tz_offset = (tm.tm_gmtoff / SEC_PER_MIN);
658  #else
659  tz_offset = -(::timezone / SEC_PER_MIN);
660  #endif
661  }
662  year = 1900 + tm.tm_year;
663  month = tm.tm_mon + 1;
664  day = tm.tm_mday;
665  hour = tm.tm_hour;
666  minute = tm.tm_min;
667  second = tm.tm_sec;
668  #endif
669  }
670 
676  static void tz_init() {
677  #if defined(__linux__)
678  // Setting TZ env var reduces stat() system calls with localtime_r()
679  const char* FILE_STR = ":/etc/localtime"; // file path with ':' prefix
680  if (::getenv("TZ") == NULL && ::access(FILE_STR + 1, R_OK) == 0)
681  ::setenv("TZ", FILE_STR, 1);
682  #endif
683  }
684 
691  static int tz_get_offset() {
692  #if defined(_WIN32)
693  TIME_ZONE_INFORMATION info;
694  if (::GetTimeZoneInformation(&info) == TIME_ZONE_ID_INVALID)
695  return 0;
696  return (int)-info.Bias;
697  #else
698  ::tzset();
699  #if defined(__FreeBSD__)
700  time_t dummy = 0;
701  struct tm tm;
702  if (localtime_r(&dummy, &tm) == NULL)
703  return 0;
704  return (int)(tm.tm_gmtoff / SEC_PER_MIN);
705  #else
706  return (int)-(::timezone / SEC_PER_MIN);
707  #endif
708  #endif
709  }
710 
711 private:
712 #if defined(_WIN32) && !defined(EVO_WIN32_NO_QPC)
713  static longl qpc_get_freq() {
714  LARGE_INTEGER freq;
715  ::QueryPerformanceFrequency(&freq);
716  assert( freq.QuadPart > 0 );
717  return freq.QuadPart;
718  }
719 #endif
720 };
721 
723 
724 }
725 #endif
Holds a system timestamp as native (platform specific) fields.
Definition: systime.h:27
void clear()
Clear and reset as 0.
Definition: systime.h:307
int compare(const SysTimestamp &oth) const
Compare to another timestamp.
Definition: systime.h:498
void set_cpu()
Set as current CPU (process) time for use by timers.
Definition: systime.h:435
void set_utc()
Set to current date/time (UTC).
Definition: systime.h:149
SysNativeTimeStamp & operator=(const SysNativeTimeStamp &src)
Assignment operator.
Definition: systime.h:256
static const int SEC_PER_MIN
Number of seconds per minute.
Definition: systime.h:180
void set_wall_timer()
Set as current real (wall clock) time for use by timers.
Definition: systime.h:392
Evo implementation detail for system portability – this is included by most Evo headers, include this via: include <evo/type.h>.
SysTimestamp()
Constructor.
Definition: systime.h:287
void add_msec(ulong new_msec)
Add milliseconds to current time.
Definition: systime.h:467
ulongl diff_msec(const SysTimestamp &start) const
Use this as an end-time and get the difference from start time in milliseconds.
Definition: systime.h:514
SysTimestamp(const SysTimestamp &src)
Copy constructor.
Definition: systime.h:293
ulongl diff_nsec(const SysTimestamp &start) const
Use this as an end-time and get the difference from start time in nanoseconds.
Definition: systime.h:534
struct timeval Fields
Definition: systime.h:145
void convert_utc_dt(DT &dt) const
Convert current date/time to DateTime holding UTC.
Definition: systime.h:187
ulongl diff_usec(const SysTimestamp &start) const
Use this as an end-time and get the difference from start time in microseconds.
Definition: systime.h:524
struct timeval ts
Definition: systime.h:146
ulongl sec
Number of seconds since Jan 1, EPOCH_YEAR.
Definition: systime.h:283
static void get_wall_datetime_fields_local(int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond, int &tz_offset)
Get fields for current real (wall clock) time for calendar date/time use (Local Time).
Definition: systime.h:635
void set_wall_datetime()
Set as current real (wall clock) time for calendar date/time use.
Definition: systime.h:358
Evo C++ Library namespace.
Definition: alg.h:11
void convert_local_dt(DT &dt) const
Convert current date/time to DateTime holding Local Time, including timezone offset.
Definition: systime.h:204
long get_nsec() const
Get current fractional second value in nanoseconds.
Definition: systime.h:174
void convert_local_dt_notz(DT &dt) const
Convert current date/time to DateTime holding Local Time, without storing timezone offset...
Definition: systime.h:227
static void get_wall_datetime_fields_utc(int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond)
Get fields for current real (wall clock) time for calendar date/time use (UTC).
Definition: systime.h:552
static void tz_init()
Initializater that optimizes timezone (local time) conversion in some cases.
Definition: systime.h:676
int64 get_unix_timestamp() const
Get current date/time as Unix timestamp.
Definition: systime.h:159
static void get_wall_datetime_fields_local(int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond)
Get fields for current real (wall clock) time for calendar date/time use (Local Time).
Definition: systime.h:593
SysTimestamp & operator=(const SysTimestamp &src)
Assignment operator.
Definition: systime.h:300
SysNativeTimeStamp(const SysNativeTimeStamp &src)
Copy constructor.
Definition: systime.h:249
SysNativeTimeStamp()
Constructor.
Definition: systime.h:243
Holds a system timestamp for storing date/time and measuring elapsed time.
Definition: systime.h:269
static int tz_get_offset()
Get current time zone (local time) offset from UTC in minutes.
Definition: systime.h:691
int get_msec() const
Get current fractional second value in milliseconds.
Definition: systime.h:166
ulong nsec
Number of nanoseconds from seconds.
Definition: systime.h:284
void add_nsec(ulongl new_nsec)
Add nanoseconds to current time.
Definition: systime.h:483