GNOME Bugzilla – Bug 334648
Date sometimes wrongly parsed in British locale.
Last modified: 2008-11-20 18:56:10 UTC
Case 1: In a en_GB locale, entering "01/02/1973" results in "01/02/19". This seems to be a problem with std::time_get<>::get_date(), which we try first. Strangely, it succeeds (also using std::time_get<>::get_date()) when entering "01.02.1973". or "01-02-1973", though the "correct" separator seems to be "/". Well, that's what's used for display when we get a text representation using std::time_put<>::put(). Case 2: In a en_GB locale, entering "01/02/04" results in "01/02/04", but that 04 has actually been stored internally as 1904. There's a reasonable expectation that it would be 2004. If we can fix the display to always use 4 digits, even in a british locale, then the user would see, and could specify exactly what they want. (In an en_US locale, it displays and parses 4-digit years. I'd prefer to never show 2 digit years, in any locale, to avoid confusion.)
Created attachment 61295 [details] testdateput_allformats.cc Example code from roguewave's std::time_put documentation, listing result of all formats in the current locale.
Created attachment 61296 [details] time_put_all_formats.txt Output from the roguewave examples (logged into a british locale - $LANG=en_GB.UTF-8), showing that none of the formats shows 4 digits for the year.
Created attachment 61299 [details] testdateput_allformats.cc Corrected, to actually use the current locale. Roguewave's example was not that great, though at least they have an example.
Created attachment 61300 [details] time_put_all_formats_en_GB.txt
Created attachment 61301 [details] time_put_all_formats_en_US.txt USA (uses 4 digits)
Created attachment 61302 [details] time_put_all_formats_de.txt Germany (Uses 4 digits)
I have reported the time_put problem in the g++ bug database: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26697
And here is the g++ bug for time_get(): http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26701 I will have to work around this lack in the C++ standard, in some locales. I have an idea how to do that.
Fixed, by making the "%x" format translatable, so that translators can choose, for instance, %d/%m/%Y instead, if their locale is "broken".
(In reply to comment #3) > Created an attachment (id=61299) [edit] > testdateput_allformats.cc > > Corrected, to actually use the current locale. Roguewave's example was not that > great, though at least they have an example. That crashes for me on Ubuntu Intrepid, though I can't figure out why.