Re:The Kobayashi Maru of comparing dates with times
by hashimotonomora on Saturday February 12, 2022 @06:42PM
(#30317519)
You can define a type cast but it’s arbitrary.
[ Parent
| on HN ]
Re:The Kobayashi Maru of comparing dates with times
by danbruc on Saturday February 12, 2022 @06:52PM
(#30317598)
If the date is, for example, the starting date of a contract, then the date is most likely just a shorthand for 00:00:00 on that date. With that there is no problem at all comparing the date with an instant and decide whether the instant is before or after the contract went into effect. This is not arbitrary, this is making explicit use of otherwise implicit domain knowledge.
Re:The Kobayashi Maru of comparing dates with times
by Spivak on Saturday February 12, 2022 @06:59PM
(#30317643)
All comparators are arbitrary, even among same-typed objects.
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.