Found by tests/lib/libc/time (not shipped yet).
We fail the following century/year test cases:
strptime("x2084y", "x%C%yy", tm): incorrect tm_year: expected: 184, but got: 84 strptime("x8420y", "x%y%Cy", tm): incorrect tm_year: expected: 184, but got: 100 strptime("%20845", "%%%C%y5", tm): incorrect tm_year: expected: 184, but got: 84
The problem here is that we don't check if we have %C conversion in the format string when processing %y, and as %C can come *after* %y, fix this by calculating tm_year after we have finished processing the format string.
Also do NOT fail if resulting tm_year is negative based on the APPLICATION USAGE in http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html (glibc does the same):
tm_year is a signed value; therefore, years before 1900 may be represented.
Konstantin, it's not clear to me who else can/should be added to reviewers, need an advise here (hackers@?).