This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

time_get<>::get_year() reading fewer than four digits


Our get_year() function parses two digits as 19NN, which might be
reasonable if you believe that no sane person uses two-digit years
nowadays, so two-digit years must come from ye olde data files from
last millennium. An alternative would be to follow POSIX (as Visual
C++ and libc++ do) and treat [00,68] as 20NN and [69,99] as 19NN.
Another alternative would be to simply assume the current century, so
20NN.

It parses three digits as a two-digit year that overflows the maximum
value of 99, so the result is 1999 and failbit is set. That's arguably
not very useful, and makes it impossible to parse years such as 325
AD, although maybe only the Vatican would notice that problem.

At the very least we need to document our implementation-defined
semantics for two-digit years. We might also want to change how we
handle fewer than four digits. I think there's an LWG issue on the
way, so we can wait and see what LWG decides is the right behaviour.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]