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

It's because there's no right answer, and this way gets you the intuitive answer most often.

A month isn't a proper unit of time. Adding a month to a date can't be done without specifying which month you're adding.

You could argue that one month from January 31 is February 28, 29 (depending on the year), March 2, or 3.

Should one month from the last day be the last day of the next month? That would mean that the 30th and the 31st of march are both the same duration from April 30th, and a month before April 30th could logically map to either one.

So they chose the path that, for anything other than the 31st, and the 29th and 30th if it comes near February, works as you expect. "A month after 17 days from the first of January is 17 days after the first of february.”

The other alternatives involve not allowing the addition and subtraction of irregular time intervals, but then you get frustrated that you can only deal with seconds, since those don't change in length.

this post was submitted on 06 Nov 2023
30 points (68.3% liked)

Programmer Humor

32745 readers
280 users here now

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

Rules:

founded 5 years ago
MODERATORS