this post was submitted on 14 Dec 2023
213 points (95.7% liked)

Programmer Humor

32397 readers
812 users here now

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

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 3 points 10 months ago (1 children)

Until you need to decide how many months are between t1 and t2, and then all answers are wrong.

[โ€“] [email protected] 2 points 10 months ago* (last edited 10 months ago)

To do that you first need to choose a calendar and a time zone, then convert to that representation. It can be done, but you need a good implementation that understands the entire history of what has transpired w.r.t. to date conventions in that location and culture. For timestamps in the future it is impossible to do correctly, since you can't know how date conventions will change in the future.

However, I should add that as far as mathematical operations go, calculating the number of months between t1 and t2 is an entirely different thing than the duration of time that passed between those timestamps. Even if it is expressed similarly in the English language, semantically it's something else. It's like asking "how many kilometers did your car go" vs "how many houses did the car pass on the way".