49#define TIME_T_MIN ((time_t) ((time_t)0 < (time_t) -1 ? (time_t) 0 \
50 : (time_t) (~0ULL << (sizeof (time_t) * CHAR_BIT - 1))))
53#define TIME_T_MAX ((time_t) (~ (time_t) 0 - TIME_T_MIN))
59#define NSTIME_INIT_ZERO {0, 0}
62#define NSTIME_INIT_UNSET {0, INT_MAX}
65#define NSTIME_INIT_SECS_NSECS(secs, nsecs) {(secs) + ((nsecs) / 1000000000), (nsecs) % 1000000000}
68#define NSTIME_INIT_SECS_USECS(secs, usecs) {(secs) + ((usecs) / 1000000), ((usecs) % 1000000) * 1000}
71#define NSTIME_INIT_SECS_MSECS(secs, msecs) {(secs) + ((msecs) / 1000), ((msecs) % 1000) * 1000000}
74#define NSTIME_INIT_SECS(secs) {secs, 0}
77#define NSTIME_INIT_MAX {TIME_T_MAX, INT_MAX}
183#define nstime_add(sum, a) nstime_sum(sum, sum, a)
194#define nstime_subtract(sum, a) nstime_delta(sum, sum, a)
312#define NSTIME_ISO8601_BUFSIZE sizeof("YYYY-MM-DDTHH:MM:SS.123456789Z")
332#define NSTIME_UNIX_BUFSIZE (20+10+1)
374#define WS_TSPREC_MAX 9
382#define NUM_WS_TSPREC_VALS (WS_TSPREC_MAX + 1)
406#define nstime_round(a, prec) nstime_rounded(a, a, prec)
ws_tsprec_e
Timestamp precision levels.
Definition nstime.h:354
@ WS_TSPREC_USEC
Definition nstime.h:361
@ WS_TSPREC_100_NSEC
Definition nstime.h:362
@ WS_TSPREC_100_MSEC
Definition nstime.h:356
@ WS_TSPREC_100_USEC
Definition nstime.h:359
@ WS_TSPREC_NSEC
Definition nstime.h:364
@ WS_TSPREC_MSEC
Definition nstime.h:358
@ WS_TSPREC_10_MSEC
Definition nstime.h:357
@ WS_TSPREC_10_USEC
Definition nstime.h:360
@ WS_TSPREC_SEC
Definition nstime.h:355
@ WS_TSPREC_10_NSEC
Definition nstime.h:363
WS_DLL_PUBLIC double nstime_to_msec(const nstime_t *nstime)
Converts a time value to milliseconds.
Definition nstime.c:249
WS_DLL_PUBLIC void nstime_sum(nstime_t *sum, const nstime_t *a, const nstime_t *b)
Calculates the sum of two time values.
Definition nstime.c:151
WS_DLL_PUBLIC void nstime_set_unset(nstime_t *nstime)
Marks the given nstime_t as "unset".
Definition nstime.c:53
WS_DLL_PUBLIC size_t nstime_to_iso8601(char *buf, size_t buf_size, const nstime_t *nstime)
Converts an nstime_t to an ISO 8601 formatted string.
Definition nstime.c:679
WS_DLL_PUBLIC void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a)
Calculates the time delta between two timestamps.
Definition nstime.c:85
WS_DLL_PUBLIC void nstime_set_zero(nstime_t *nstime)
Sets the given nstime_t to zero.
Definition nstime.c:31
WS_DLL_PUBLIC bool filetime_ns_to_nstime(nstime_t *nstime, uint64_t nsfiletime)
Converts a nanosecond-based FILETIME to nstime.
Definition nstime.c:337
WS_DLL_PUBLIC bool nstime_is_unset(const nstime_t *nstime)
Checks whether the given nstime_t is marked as "unset".
Definition nstime.c:60
iso8601_fmt_e
Definition nstime.h:275
@ ISO8601_DATETIME_AUTO
Definition nstime.h:278
@ ISO8601_DATETIME_BASIC
Definition nstime.h:277
WS_DLL_PUBLIC int nstime_cmp(const nstime_t *a, const nstime_t *b)
Compares two time values.
Definition nstime.c:200
WS_DLL_PUBLIC bool nstime_is_zero(const nstime_t *nstime)
Checks whether the given nstime_t is zero.
Definition nstime.c:38
WS_DLL_PUBLIC bool filetime_to_nstime(nstime_t *nstime, uint64_t filetime)
Converts a Windows FILETIME to nstime.
Definition nstime.c:313
WS_DLL_PUBLIC void nstime_copy(nstime_t *a, const nstime_t *b)
Copies one nstime_t value to another.
Definition nstime.c:74
WS_DLL_PUBLIC unsigned nstime_hash(const nstime_t *nstime)
Computes a hash value for a time value.
Definition nstime.c:237
WS_DLL_PUBLIC void nstime_rounded(nstime_t *a, const nstime_t *b, ws_tsprec_e prec)
Rounds a time value to the specified precision.
Definition nstime.c:264
WS_DLL_PUBLIC double nstime_to_sec(const nstime_t *nstime)
Converts a time value to seconds.
Definition nstime.c:259
WS_DLL_PUBLIC void nstime_to_unix(char *buf, size_t buf_size, const nstime_t *nstime)
Converts an nstime_t to a Unix timestamp string.
Definition nstime.c:730
WS_DLL_PUBLIC bool filetime_1sec_to_nstime(nstime_t *nstime, uint64_t filetime)
Converts a second-based FILETIME to nstime.
Definition nstime.c:358
WS_DLL_PUBLIC const char * iso8601_to_nstime(nstime_t *nstime, const char *ptr, iso8601_fmt_e format)
Parses an ISO 8601 formatted datetime string into an nstime_t.
Definition nstime.c:397
WS_DLL_PUBLIC bool nstime_is_negative(const nstime_t *nstime)
Checks whether the given nstime_t is negative.
Definition nstime.c:44
WS_DLL_PUBLIC const char * unix_epoch_to_nstime(nstime_t *nstime, const char *ptr)
Parses a Unix epoch timestamp string into an nstime_t.
Definition nstime.c:618