Things I learned while developing a billing system
My personal favorite: how long is a month?<p>- <i>An even 30 days</i> = Easy to explain and do math with. Adding/subtracting 1 month can leave you in the same month or skip February entirely! Anniversary dates bounce around from month-to-month. Maps poorly to yearly calculations.<p>- <i>However many days >this< month has</i> = Harder to explain and do math with. Months without 31 days can get skipped when adding/subtracting 1 month. Recurring events get pushed away from the end of the month to cluster around the beginning of the month. It does result in a steady anniversary date for edge cases.<p>- <i>Closest numeric day, but prev/next month</i> (e.g. Jan 31 -> Feb 28): Easy <i>and</i> hard to explain and do math with. It's great for ensuring events only ever happen once per calendar month, but adds extra ambiguity (e.g. Jan 31 > Feb 28 > March 30? ... or March 28th?)<p>- <i>30.4...</i> = Just no... except for the few times this is right and you need consistency to avoid unfairly comparing 28 days vs 31 days.<p>The consequence is some very surprising things the first time you see them. Some billing systems simply avoid doing work past the 28th of each month (either doing it a bit early or a bit late). Some just embrace the weirdness (whichever you flavor you pick) and you get used to the quirks (e.g. end-of-month lulls and start-of-month spikes).