| I think months from 0 in POSIX were intentional, not mistakes. The things you might want to do with an integer month number include: 1. Look up some attribute or property of the month in a table (number of days in the month in a non-leap year, name of the month, list of fixed holidays in the month, etc). 2. Determine if the month is before or after a different month. 3. Determine how many months one month is after or before another month. 4. Determine which month is N months before/after a given month. 5. Print the month number for a human. In languages that use 0-based indexing: #1 is more convenient with 0-based months. #2-4 only need that the month numbers form an arithmetic progression, so are indifferent to where we start counting. #5 is more convenient with 1-based months. So it comes down to is it better to have your low level date functions require that you have to remember to subtract 1 whenever you do something from #1, or to add 1 whenever you do something from #5? I'd expect most programs do a lot more #1 than #5, so the code is going to be cleaner if you go with 0-based months. |
I'm glad most modern date APIs use 1-based numbers to represent the month and the day (not to mention the year from 1 AD onwards).