Pretty sure these are the two cases which the python stdlib datetime covers.
The question is whether the definition is useful or not.
Moreover, there isn't anything intrinsically wrong with that. To go one "why" deeper, the problem is in the human brains that insist that such an operator simply must exist. How can we not do equality on times and dates? To which the answer is that your incredulity isn't really relevant and certainly doesn't create a universal answer.
Perhaps one "why" below that is a shallow understanding of operators in general, as Spivak references in a, err, nephew post of this one. If your concept of equality is that it was handed down from on high by your fourth grade teacher, you may have trouble dealing with the fact that there's really nothing special about it from a programming perspective, and programming routinely uses multiple concepts of "equality" even before we get into fundamentally ambiguous type comparisons! For instance, == vs. === in Javascript is two right there. Arguing about which is "the" equality operator is fundamentally flawed on the grounds that there really isn't such a privileged position of "the" equality operator to be occupied in the first place. We define many equality-like operators all the time, suitable for whatever local needs we have, and while there are certainly some that are more "equality-like" than others there is even so quite a few to chose from.
The ambiguity must be embraced and dealt with... or you will experience the implacable, impersonal engineer consequences of failing to do so, whatever those consequences may be for you in your particular situation.
You can define a poset on the natural numbers ordered by divisibility that’s well defined and different from the usual < relation.
Pulling an example from maths, comparisons between integers and rationals are well defined despite them not being the same type. The obvious ordering uses the n <-> n/1 mapping but it doesn’t have to.
Looked at as ranges, equality can be defined as whether they overlap, and that works for most use cases but not all.
I’d argue though, that without context, a date has the time 00:00 in your local time zone.
I'd argue that without context a Date cannot have any time inferred. In the programming context it should be treated as a programming error and comparisons should fail to compile unless additional context is given.
A lot of the confusion here seems to stem from how we traditionally store dates (seconds/millis after a reference point in time), and over time we've confused the predominant way in which the data is represented from what the data actually is intended to mean.
let date1 = Date("06/05/2022")
let date2 = DateTime("06/05/2022 20:05 UTC")
if date2 > date1 {
// SHOULD NOT COMPILE
}
let date3 = Date("06/05/2022").withTime("05:00 UTC")
if date2 > date3 {
// DOES COMPILE
}
Injecting context automatically without the intentional action/declaration of the programmer is where a billion bugs are born.These guys are comparing things that they know is a date only with something that needs a time stamp.
My mental model for these kinds of things is that Times are instants and Dates are either:
1. Ranges (with the start and end Time depending on TZ and possibly other context)
2. Discrete cells of a calendar (which are mostly TZ independent - July 5th doesn't happen at the same time everywhere, but it is well-defined everywhere)
Also, I've been writing code for 25 years and I still have no idea what a DateTime is.