-
What data type to use for timestamps?
- int?
- int32_t?
- uint64_t?
- int64_t?
-
Why not
int32_t?- Overflow in January 19th, 2038
- Similar to
y2k(dates went from99to00) - Cost $300B - 600B to update legacy systems
- Similar to
int64_tprovides a range of 292 billion years
- Overflow in January 19th, 2038
-
Why used
signedinstead ofunsigned?- Prevent underflow
- Handles negative nums from clock jitter (Time A - Time B)
- Crashes when unsigned integer wraps around to
18.4quintillion)
- Historical dates
- Unsigned types are strictly limited to the future.
- Represent time before the Unix Epoch (January 1, 1970)
- Prevent underflow
-
Why Senior C++ Engineers Never Use int for Time
-
How a Single int Can Crash Your C++ Code in 2038
-
The 2038 Bug: Why int64_t is the Only Safe Choice in C++
-
The Only Safe C++ Choice for Timestamps is int64_t
-
Why int64_t is the Only Safe Choice in C++
-
int vs int64_t: Avoiding the Silent C++ Gotcha
- ChatGPT and Gemini