I\'m looking for standards for Date/Time addition. I haven\'t been able to find any. In particular I\'m hoping to find a spec that defines what should happen when you add a mont
According to the POSIX.1-2001 standard, next month (as in incrementing tm_mon
before calling mktime
) is done by adjusting the values until they fit. So, for example, next month from January 31, 2001 is March 3, 2001. This is because the tm_mday
of 31 isn't valid with tm_mon
of 1 (February), so it is normalized to tm_mon
of 2 (March) and tm_mday
of 3.
The next month from January 31, 2000 is March 2, 2000, because Feb. has 29 days that year. The next month from January, 1 2038 doesn't exist, depending.
The great thing about standards is there are so many to chose from. Check the SQL standard, I bet you can find a different meaning of next month. I suspect ISO 8601 may give you yet another choice. Point is, there are many different behaviors, the meaning of 'next month' is very domain-specific.
edit: I think I've found how SQL-92 handles it, apparently asking for next month from January 31 is an error.
Links: