Hacker News new | past | comments | ask | show | jobs | submit login

Caveat:

The date's range isn't always 24 hours exactly.

Leap seconds can make it slightly longer.

A daylight savings change makes the date's range 23 or 25 hours, depending on the direction.

I would not be surprised if someone popped up with more edge cases I haven't thought of.

Dates and times are crazy.




If you're treating dates as ranges, then even ignoring the timezones and daylight savings it still doesn't mean that a date implies a range from 00:00 to 24:00 - the mapping is inherently domain-specific and thus depends on the particular interpretation of that date field (thus it's nonsensical to expect a generic answer/comparison rule for "dates" i.e. all dates).

For example, in the domain of financial settlement, a future date of 2022-03-03 would imply that the event must happen by the end of business day of 2022-03-03 (and thus an event at 23:00 of 2022-03-03 would be too late and would map to 2022-03-04 instead); and in a similar manner, the appropriate date for any events happening in the middle of a sunday would be either monday or friday depending on what your rules are, as the effective date which you would be using to calculate the number of days between two events (for e.g. interest) in may jurisdictions has to be a business day; so two events timpestamped five minutes apart might need to be treated as if they are on the same day, different days, or in some cases many days apart (e.g. with a combination of Christmas + weekend).

Different domains will have different rules; the generic concept of "date" is too vague to define an universal comparison operator and you have to look at the meaning of each specific date field/variable and expect different date fields/variables to need different semantics.


This is an excellent point. Thank you for sharing it!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: