News for hackers. Stuff that matters.
Re:Things I learned while developing a billing system by greggyb on Tuesday April 06, 2021 @12:08AM (#26707864)
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....

Re:Things I learned while developing a billing system by arnon on Tuesday April 06, 2021 @02:06AM (#26708456)
All 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!