• DaGeek247@fedia.io
    link
    fedilink
    arrow-up
    47
    ·
    1 day ago

    JavaScript Date objects are cursed

    JavaScript date objects are 1 indexed for years and days, but 0 indexed for months.

    Oh that’s not nearly the only thing javascript fucks up about their Date() implementation. https://jsdate.wtf/

      • cley_faye@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        10 hours ago

        Backward compatibility and not seeing the future. Some decisions are taken at one point in time, then a new use case show up, then a new paradigm evolve, then… etc etc.

        It’s really the same thing that holds back a lot of languages and libraries. And even when replacement shows up, old habits from devs and old projects maintenance keep all these things well alive too.

      • brian@programming.dev
        link
        fedilink
        arrow-up
        5
        ·
        17 hours ago

        early js/html liked to do something in all cases instead of throwing or whatever. I think it’s mostly just a collection of them trying to do something smart on nonsense input and not being consistent about it.

        side note, I’m so excited for Temporal, some browsers already support it and you can polyfill for the rest.

      • Kevin@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        19 hours ago

        I can only imagine it wasn’t planned properly, cuz that’s so many quiet behaviours without good parsing errors