25 #ifndef HYPERTABLE_TIMEINLINE_H
26 #define HYPERTABLE_TIMEINLINE_H
39 #ifndef HT_DELIM_CHECK
40 # define HT_DELIM_CHECK(_l_, _c_) do { \
42 throw std::runtime_error("expected " #_l_ " to be " #_c_); \
46 #ifndef HT_RANGE_CHECK
47 # define HT_RANGE_CHECK(_v_, _min_, _max_) do { \
48 if ((_v_) < (_min_) || (_v_) > (_max_)) \
49 throw std::range_error(#_v_ " must be between " #_min_ " and " #_max_); \
65 const int64_t
G = 1000000000LL;
71 tv.tm_year = strtol(ts, &last, 10) - 1900;
73 tv.tm_mon = strtol(last + 1, &last, 10) - 1;
76 tv.tm_mday = strtol(last + 1, &last, 10);
80 return mktime(&tv) *
G;
83 tv.tm_hour = strtol(last + 1, &last, 10);
86 tv.tm_min = strtol(last + 1, &last, 10);
90 return mktime(&tv) *
G;
94 tv.tm_sec = strtol(last + 1, &last, 10);
99 ns = strtol(last+1, &last, 10);
100 else if (*last ==
'.')
101 ns = (int64_t)(strtod(last, 0) * 1000000000.0);
103 return (int64_t)(mktime(&tv) * G + ns);
Retrieves system information (hardware, installation directory, etc)
#define HT_DELIM_CHECK(_l_, _c_)
static void initialize_tm(struct tm *tmval)
Initialize struct tm.
Time related declarations.
int64_t parse_ts(const char *ts)
Inline function which parses a string with a timestamp in localtime and returns a 64bit nanosecond ti...
#define HT_RANGE_CHECK(_v_, _min_, _max_)