I guess that the fundamental problem is thinking of months and years as numbers (and representing them as such).
If they were purely symbolic constants, then the expression "January + 1" is meaningless and would throw an error.
So, with hindsight, I'd say that any Datetime api which represents days, months and years as numeric quantities (which is, probably, all of them) encourages these kinds of bugs. (Or at least doesn't discourage them).
Can anyone come up with a use case where you need numeric values for these things? (Which doesn't suffer from the same kind of bugs as this?)
Comments
I guess that the fundamental problem is thinking of months and years as numbers (and representing them as such).
If they were purely symbolic constants, then the expression "January + 1" is meaningless and would throw an error.
So, with hindsight, I'd say that any Datetime api which represents days, months and years as numeric quantities (which is, probably, all of them) encourages these kinds of bugs. (Or at least doesn't discourage them).
Can anyone come up with a use case where you need numeric values for these things? (Which doesn't suffer from the same kind of bugs as this?)