Task #9320 (closed)
Bug: Insight does not repect the user's locale when displaying dates and timestamps
Reported by: | rleigh | Owned by: | jburel |
---|---|---|---|
Priority: | major | Milestone: | OMERO-4.4.4 |
Component: | Insight | Version: | n.a. |
Keywords: | n.a. | Cc: | |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | n.a. |
Sprint: | 2012-08-14 (2) |
Description
Insight is displaying the acquisition date in US MM/DD/YYYY format (see attached example, which should be the 9th of February, rather than the 2nd of September). Please use the locale date format e.g. the java equivalent of the %c or %x strftime conversion specs, or else the date is ambiguous and confusing.
Attachments (1)
Change History (9)
Changed 12 years ago by rleigh
comment:1 Changed 12 years ago by jburel
- Milestone changed from OMERO-Beta4.4 to OMERO-Beta4.4.1
comment:2 Changed 12 years ago by jburel
comment:3 Changed 12 years ago by rleigh
% locale LANG="en_GB.UTF-8" LC_COLLATE="en_GB.UTF-8" LC_CTYPE="en_GB.UTF-8" LC_MESSAGES="en_GB.UTF-8" LC_MONETARY="en_GB.UTF-8" LC_NUMERIC="en_GB.UTF-8" LC_TIME="en_GB.UTF-8" LC_ALL=
This should be respected by the program. In C, one would call
setlocale(LC_ALL, "");
or with C++
try { std::locale::global(std::locale("")); } catch (std::runtime_error const& e) // Invalid locale { std::locale::global(std::locale::classic()); } std::cout.imbue(std::locale()); std::cerr.imbue(std::locale());
All the standard formatting functions will then use the correct locale-specific numeric and date formatting conventions. Here's an example for one of my programs, showing the C++ standard library date formatting:
% LANG=C schroot --config | head -n 1 # schroot configuration generated by schroot 1.4.22 on 08 Aug 2012 % LANG=en_GB.UTF-8 schroot --config | head -n 1 # schroot configuration generated by schroot 1.4.22 on 08 Aug 2012 % LANG=fr_FR.UTF-8 schroot --config | head -n 1 # Configuration schroot générée par schroot 1.4.22 le 08 août 2012 % LANG=de_DE.UTF-8 schroot --config | head -n 1 # schroot-Konfiguration erzeugt von schroot 1.4.22 am 08. August 2012 % LANG=sv_SE.UTF-8 schroot --config | head -n 1 # schroot-konfiguration genererad av schroot 1.4.22 den 08 aug 2012 % LANG=en_US.UTF-8 schroot --config | head -n 1 # schroot configuration generated by schroot 1.4.22 on 08 Aug 2012
None of the date formatting is built into the code--it's using the system locales. It must surely be possible to do the equivalent in Java. Even the C printf() does locale-specific numeric formatting.
Regards,
Roger
comment:4 Changed 12 years ago by jburel
Mystery solved:
On OS X, if the language is set to English the Locale.getDefault() will have the country as US see System.getProperty(user.country).
In order to have the country set to GB, you have to set the language to British English.
I will now review the methods we have currently in place to format the date.
comment:5 Changed 12 years ago by jburel
- Sprint set to 2012-08-14 (2)
comment:6 Changed 12 years ago by jburel
- Resolution set to fixed
- Status changed from new to closed
comment:7 Changed 12 years ago by rleigh
Works correctly for me with this change. The dates are now formatted in the correct format for the UK on both Mac and Linux, both of which are configured for a UK locale.
comment:8 Changed 12 years ago by jburel <j.burel@…>
(In [bc8320aaddd81c2133ed4543fa167583fe86d6a8/ome.git] on branch develop) Make sure the dates are displayed using Locale (see #9320)
Default locale is US.
Did you set another on your machine?
An option will be to always display the ISO date time.