3 ms·
It's difficult to answer how many seconds are between two times because whether there was a leap second or not is not the result of an algorithm. Leap seconds a
by curryst 6y ago
It's difficult to answer how many seconds are between two times because whether there was a leap second or not is not the result of an algorithm. Leap seconds are added to keep time synchronized to the rotation of the earth (i.e. so noon is when the sun is at its apex).
You're better with something like epoch time because the duration between two times is always the absolute value of their subtraction. You don't have to store a chart to figure out whether the difference in wall time between 3:03:03 and 03:03:05 is 2 seconds or if there was a leap second and it should be 3 seconds.
You can do it, but you have to check the behavior of all your libraries. Which isn't fun. And make sure that somebody doesn't do an optimization that switches the behavior at some point.