Over the years, I have come across various interpretations of the end of the day. But what is the correct way to present it when comparing dates and intervals?
I found that some people prefer 23:59:59 , while others use 00:00:00 .
Here at StackOverflow, I even found some examples of questions related to using and displaying 24:00:00 , however the scope of this question is more focused on determining how to divide the two days.
In other words, we are interested in the problem of determining where exactly the day ends and where the next begins. This is apparently a common problem in many applications that require even the simplest comparisons or time slot calculations.
To clarify the above interpretations, below are three examples representing January 1 st 2014 under three different interpretations:
- Quasi Midnight :
2014-01-01 00:00:00 - 2014-01-01 23:59:59 - Midnight sharp :
2014-01-01 00:00:00 - 2014-01-02 00:00:00 - Military Midnight :
2014-01-01 00:00:00 - 2014-01-01 24:00:00
While I feel that the quasi-midnight interpretation is the most intuitive, it also seems to require enough templates to correctly indicate the time. In addition, the risk of encountering red cases when the last second part of the day is not properly handled, or the risk of affecting performance when scanning huge collections of intervals for testing around these gaps.
Similarly, the military midnight interpretation also seems to require some template to tweak this split point. Without thinking too much, I cannot come up with a lot of complications using this approach.
Finally, the midnight harsh interpretation seems to be a good candidate for the most consistent. Unlike midnight, it does not require a template for setting the time and, of course, behaves with the operators < , <= , > and >= .
It is worth noting that the PHP language already interprets 2014-01-01 24:00:00 as 2014-01-02 00:00:00 , which leads to the conversion of the date into an accurate, clear interpretation of the date.
Are there any remarkable precedents in the FLOSS reference libraries or standards that justify using one interpretation over another?