31
you are viewing a single comment's thread
view the rest of the comments
[-] ricecake@sh.itjust.works 3 points 1 year ago

In this case though, it's consistent, and is just one of the annoying ways the problem could be solved. Datetime math is just fucked up.

You can just not support that functionality, which gives you people making their own mistakes and forgetting leap years or hard coding all sorts of insanity.

You can clamp the value to the end of the month, but that gives you the odd case where date + month - month != date in some days, which is also a weird pitfall.

If I see any code dealing with adding and subtracting months, I'm either checking the manual or I already know it's behavior from doing so before.
I'm all about not liking how JS does stuff, but Datetime math is the one area where in willing to forgive most insanity of outcomes.

this post was submitted on 06 Nov 2023
31 points (69.1% liked)

Programmer Humor

32342 readers
1360 users here now

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

Rules:

founded 5 years ago
MODERATORS