4 ms·
Don't forget that calendar math is not commutative! Jan 27 + 5 days = Feb 1 Feb 1 + 1 month = Mar 1 Jan 27 + 1 month = Feb 27 Feb 27 + 5 day
by greggyb 6y ago
Don't forget that calendar math is not commutative!
Jan 27 + 5 days = Feb 1
Feb 1 + 1 month = Mar 1
Jan 27 + 1 month = Feb 27
Feb 27 + 5 days = Mar 4 (or Mar 3 in a leap year!)
Therefore...
Jan 27 + 5 days + 1 month = Mar 1
Jan 27 + 1 month + 5 days = Mar 1
AND
Jan 27 + 5 days + 1 month = Mar 4 (or 3)
Jan 27 + 1 month + 5 days = Mar 4 (or 3)
Before someone claims that this is just a February problem, please first consider that you can create these scenarios with any set of months that have differing lengths.
Then, please consider that your argument that ignoring February is not a good way to approach any calendaring library....
- arnon 6y agoAll too familiar. Luckily, I have built "date time" functions for a relational DBMS before! I had specifically worked on functions like EXTRACT to pull out different parts like ISO Week numbers, as well as DATEADD and DATEDIFF functions which do date math. It is exceptionally unpleasant!