• kinttach@lemm.ee
    link
    fedilink
    English
    arrow-up
    17
    ·
    8 months ago

    The legacy Date object has many problems and this is one of them. Another infamous one is that it uses zero-based month numbers: January is the zeroth month and December the 11th month.

    This will be fixed Any Day Now™️ when Temporal is released. This is a carefully designed library that supersedes Date and is currently waiting on some standards to be finalized.

  • PM_ME_FAT_ENBIES@lib.lgbt
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    8 months ago

    Oh, because if the month you chose has less than 31 days, it’ll assume the 31st of September is the 1st of October? That’s reasonable.

      • erogenouswarzone@lemmy.ml
        link
        fedilink
        English
        arrow-up
        3
        ·
        8 months ago

        I love js. But the date object has always been a total pain. Moment.js is a good package to deal with it, but yeah, it’s currently deprecated, but it would be nice if it or something like it became part of ECMAScript.

        I have no idea why it hasn’t yet, except that it might be that js needs to work for everyone, not just the us. So time is not standard.

        • towerful@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          8 months ago

          The date API is like the original rip of the Java date API. Barely changed, and totally backwards compatible nonsense.

          Temporal is the new JavaScript/ECMAScript date API.
          It’s stage 3, and likely stable (just a few kinks being worked out). So you could polyfill it for production.
          https://github.com/tc39/proposal-temporal

          • erogenouswarzone@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            ·
            8 months ago

            Speaking of Java RipS. How annoying is it the JS has left Java in the dust as far as looser standards?

            Developing in Java: YOU FORGOT A SEMI-COLON ARE YOU CRAZY?! HOW IS THE COMPILER SUPPOSED TO KNOW WHAT TO DO?!

            Developing in JS: Who gives a fuck about semi-colons?