diggita
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
tfm@europe.pub to Programmer Humor@lemmy.ml · 3 months ago

JavaScript is awesome

jsdate.wtf

external-link
message-square
8
link
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
  • programmer_humor@programming.dev
  • programming@programming.dev
2
external-link

JavaScript is awesome

jsdate.wtf

tfm@europe.pub to Programmer Humor@lemmy.ml · 3 months ago
message-square
8
link
fedilink
  • cross-posted to:
  • programmer_humor@programming.dev
  • programmer_humor@programming.dev
  • programming@programming.dev
new Date("wtf")
jsdate.wtf
external-link
How well do you know JavaScript's Date class?

cross-posted from: https://programming.dev/post/33754840

new Date(“wtf”)

alert-triangle
You must log in or register to comment.
  • mogoh@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Ok, I get that the Date API is problematic, but I wouldn’t expect anything meaningfull from new Date("not a date").getTime() anyway. Why would you in the first place?

  • Victor@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Luckily the new Temporal API is shaping up.

    • Tlaloc_Temporal@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      I quite like this one.

  • CarrotsHaveEars@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Until the new Temporal API comes along, there are some libraries we can use.

    • luxon
    • dayjs
    • or compile chrono (Rust) to WebAssembly
  • kinttach@lemmy.zip
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    3 months ago

    In the process of being replaced.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal

    JavaScript has had the Date object for handling date and time since its first days. However, the Date API is based on the poorly designed java.util.Date class from Java, which was replaced in the early 2010s; but, because of JavaScript’s goal of backward compatibility, Date sticks around in the language.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      Hmm, I can believe that it was based on java.util.Date, but I don’t remember that being as unpredictable. I guess, a different API to begin with, would have avoided a lot of problems, though…

    • sp3ctr4l@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      Damn, I thought you meant JavaScript itself was being replaced.

      • jimi_henrik@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        One can only undefined

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 227 users / day
  • 1.23K users / week
  • 2.09K users / month
  • 2.8K users / 6 months
  • 1 local subscriber
  • 38.6K subscribers
  • 212 Posts
  • 800 Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org