diff options
| author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-02 20:36:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-02 20:36:18 -0500 |
| commit | 2341216ad744b7aee83e54c82c2fb6413258fcc8 (patch) | |
| tree | 482604dd5106d24b470dd2c8012ee77c3a43992f /src/basic/time-util.h | |
| parent | f1669917f583279ac7348283206612462b178597 (diff) | |
| parent | ed737400c207b6b909cd6168713e528771693923 (diff) | |
Merge pull request #5212 from poettering/time-range
time handling fixes
Diffstat (limited to 'src/basic/time-util.h')
| -rw-r--r-- | src/basic/time-util.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/time-util.h b/src/basic/time-util.h index f67a4474ed..7463507f51 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -181,3 +181,14 @@ static inline usec_t usec_sub(usec_t timestamp, int64_t delta) { return timestamp - delta; } + +#if SIZEOF_TIME_T == 8 +/* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit year + * territory. However, since we want to stay away from this in all timezones we take one day off. */ +#define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 253402214399000000) +#elif SIZEOF_TIME_T == 4 +/* With a 32bit time_t we can't go beyond 2038... */ +#define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 2147483647000000) +#else +#error "Yuck, time_t is neither 4 not 8 bytes wide?" +#endif |
