X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Ftime-util.h;fp=src%2Fbasic%2Ftime-util.h;h=2ea7e8b511173c461fe7d3523e442d1356530d0d;hp=4485d7eb0e3236e69c964497a5d5f0d28fa1ee87;hb=cb4c5148b5dab1eaf42347bde0368b6df916a206;hpb=6357ed92bd48120109f246b34e0fa8977a2caedc diff --git a/src/basic/time-util.h b/src/basic/time-util.h index 4485d7eb0..2ea7e8b51 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -203,3 +203,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