better handle 2038

This commit is contained in:
J. Nick Koston
2026-01-15 13:21:59 -10:00
parent e4a193a8f9
commit fe15b3e706
+2 -1
View File
@@ -35,7 +35,8 @@ void RealTimeClock::synchronize_epoch_(uint32_t epoch) {
// and prevent clock jumping backwards due to network latency
auto current = this->utcnow();
if (current.is_valid()) {
int32_t diff = static_cast<int32_t>(epoch) - static_cast<int32_t>(current.timestamp);
// Unsigned subtraction handles wraparound correctly, then cast to signed
int32_t diff = static_cast<int32_t>(epoch - current.timestamp);
if (diff >= -1 && diff <= 1) {
return;
}