News for hackers. Stuff that matters.
Re:The Kobayashi Maru of comparing dates with times by 2muchcoffeeman on Saturday February 12, 2022 @06:50PM (#30317579)
I wonder what kind of horrible design decision led to this in the first place.

I’d argue though, that without context, a date has the time 00:00 in your local time zone.

Re:The Kobayashi Maru of comparing dates with times by potatolicious on Saturday February 12, 2022 @06:54PM (#30317609)
> 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.
Re:The Kobayashi Maru of comparing dates with times by ufo on Saturday February 12, 2022 @07:10PM (#30317707)
My guess is the UI uses dates but the database backend stores it as a time or unix timestamp.
Re:The Kobayashi Maru of comparing dates with times by 2muchcoffeeman on Saturday February 12, 2022 @07:43PM (#30317921)
But that would have been fine, they know the UI uses dates only. Even if you store as a time stamp you can pull out just the year, month day. Compare as normal.

These guys are comparing things that they know is a date only with something that needs a time stamp.

Re:The Kobayashi Maru of comparing dates with times by samus on Sunday February 13, 2022 @09:24AM (#30321906)
> Even if you store as a time stamp you can pull out just the year, month day.

In general, you need a timezone for that.