- #36
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
2023 Award
- 35,005
- 21,673
If you are using a well-vetted structure, like time_t, and well-vetted routines like difftime, what you suggest will work.
The problem apparently is that people don't use difftime(time_t x, time_t y) for the difference between the times x and y, but rather roll their own.
As you say, NTP handles this fine, and it deals with clocks that are too far ahead millions of times each day with no problems. The difficulty seems to be that some code where time-keeping is missionm critical a) bypass NTP, and b) bypass the well-vetted and built-in functionality described above.
Bad choices produce bad outcomes.
The problem apparently is that people don't use difftime(time_t x, time_t y) for the difference between the times x and y, but rather roll their own.
As you say, NTP handles this fine, and it deals with clocks that are too far ahead millions of times each day with no problems. The difficulty seems to be that some code where time-keeping is missionm critical a) bypass NTP, and b) bypass the well-vetted and built-in functionality described above.
Bad choices produce bad outcomes.