I asked this question on Stack Overflow and it was closed as off-topic. I’ll ask it here hoping it will do better.
This might sound silly, but bear with me. I’ve been working a lot with intervals and dates lately. One question that bothers me: is a day really 24 hours long? I’m interested by the answer both from a theoretical and from a practical point of view.
Let’s take today for example, the day started on 13 Dec 2012 00:00:00 and according to (all) date-time implementations it will end on 14 Dec 2012 00:00:00. This is correct and the difference between the two dates is a complete 24 hours.
The problem with this is that the end date is perceived as “tomorrow”. Most people thinking that a day starts on 00:00:00 and ends on 23:59:59.
So the question is: is today a closed interval at the start, and opened at the end, like [start..end), with the end being very very close to 14 Dec 2012 00:00:00 (so not really a complete 24 hours)? Or is it actually closed at both ends with a full 24 hours between them?
8
It is obviously open/closed interval. How else do you want to create continuous interval of all days and still be able to account for mili/microseconds?
And it is obviously 24 hour long. That single second between 23:59:59 and 00:00:00 still counts.
3
Let’s take today for example, the day started on 13 Dec 2012 00:00:00 and according to (all) date-time implementations it will end on 14 Dec 2012 00:00:00
No. By convention the day starts at 00:00:00 and end at 23:59:59 (well 23:59:59.999 if you go down to milliseconds). Time is continuous, but we have to represent it by discrete values (no matter how “accurate” those values might be) and as no one time (00:00:00, for example) can exist in more than one 24 hour period we come to an agreement as to where that boundary lies.
It is therefore 24 hours long as there are 24 * 60 * 60 seconds in this interval.
There are three occasions when this isn’t true:
- When the clocks go forward for the start of daylight saving in which case that day is 23 hours long (one hour is lost).
- When the clocks go back for the end of daylight saving in which case that day is 25 hours long (one hour is repeated).
- When a leap second is added to a day to bring the time back into sync with the solar day in which case that day is 24 hours 0 minutes and 1 second long.
If it makes it easier think of the day starting at 00:00:01 and ending at 24:00:00. This is more obviously 24 hours.
5