GNOME Bugzilla – Bug 323289
bad time in mail appointments (12hour without AM/PM in 24hour locales)
Last modified: 2013-09-10 14:04:09 UTC
Version details: evolution-2.4.1 evolution-data-server-1.4.1 1. Create an appointment 19:00-20:00 2. Send it by mail to yourself Actual result: Appointment displayed as 07:00-08:00 And bad surprise after accept: Appointments is scheduled 12 hours later than it is displayed to you. Expected result: Appointment displayed as 19:00-20:00 (or in worst case as 07:00 PM-08:00 PM). 3. Accept appointment Additional note: locale used: LANG=cs_CZ.UTF-8
Seems to be problem of cs.po (sk_SK.UTF-8 shows dates correctly), but I do not see, which string is bad.
hi stanislav, dup of bug 314124? setting to NEEDINFO, please reopen after answering.
It is the same bug, the same string, but in different locale. Translators probably follow misleading time format comment and use %l or %I (comment says them, that they should use 12-hour format {this comment comes from the source}). But in European locales, use of %l seems to be illegal, because %p returns empty string, at least in many of these locales. Bug 314124 must be fixed in de.po, this bug in cs.po. I guess that there are more occurrences of this bug in other locales. sbrabec:~> LANG=C date +%l%p 2PM sbrabec:~> LANG=de_DE.UTF-8 date +%l%p 2 sbrabec:~> LANG=sk_SK.UTF-8 date +%l%p 2 sbrabec:~> LANG=en_US.UTF-8 date +%l%p 2PM
Hopefully fixed in CVS, both on HEAD and gnome-2.12. Thanks for your report.
Reopening bug. It was fixed only for cs locale, but it affects more locales and source, which gives bad translation instructions.
Confirming the bug based on the above comments.
This bug also affects the en_GB.UTF-8 locale. Interestingly, while the date(1) command returns the empty string for '%p' in this locale as with those listed by Stanislav Brabec earlier, the C library strftime function which takes a similar format string returns AM/PM for all these locales. $ LANG=en_GB date +%l%p 2 Compare with this C program: #include <stdio.h> #include <time.h> int main(int argc, char **argv) { time_t now; struct tm *tp; char tm_str[40]; time(&now); tp = localtime(&now); strftime(tm_str, sizeof(tm_str), "%l%p", tp); puts(tm_str); return 0; } When run at 14:43 it gives the following output: 2PM It seems the writers of date(1) and strftime(3) took two different approaches to this issue. For strftime(3) it seems to return AM/PM unless there is a translation and for date(1) it returns the empty string if there isn't a translation. As far as I know the 24 hour clock is widely used in Europe which perhaps explains the absense of translations for AP/PM in many European locales though 24 hour and 12 hour clock are both in use in the UK. In the UK, at least, the inclusion of a leading zero on a time effectively says "this is 24 hour clock" so whereas a time of 2:45 is abiguous but would probably be assumed to be in the afternoon, 02:45 is clearly in the middle of the night. One solution would be that if a locale defines AM/PM translations we assume that means 12 clock is the norm for that locale and we should use it, otherwise we should assume 24 hour clock. The following short C program demonstrates how this could be done: #include <langinfo.h> #include <locale.h> #include <stdio.h> #include <time.h> int main(int argc, char **argv) { const char *am_str; const char *format; time_t now; struct tm *tp; char tm_str[40]; setlocale(LC_ALL, ""); am_str = nl_langinfo(AM_STR); format = (am_str && *am_str) ? "%l:%M %p" : "%H:%M"; time(&now); tp = localtime(&now); strftime(tm_str, sizeof(tm_str), format, tp); puts(tm_str); return 0; } As an example, compiling this to an executable called 'td' it gives: $ LANG=C ./td 3:35 PM $ LANG=en_US.UTF-8 ./td 3:35 PM $ LANG=en_GB.UTF-8 ./td 15:35 $ LANG=de_DE.UTF-8 ./td 15:35 $ LANG=sk_SK.UTF-8 ./td 15:35 There is a further, minor, issue in that the user can set LANG to a locale that has not been built for the C library installed on their system. In this case it will default to the C locale behaviour which would give 12 hour clock output. If it is desired to give 24 hour output in this case an extra test can be introduced: #include <langinfo.h> #include <locale.h> #include <stdio.h> #include <time.h> int main(int argc, char **argv) { const char *locale_name; const char *am_str; const char *format; time_t now; struct tm *tp; char tm_str[40]; am_str = NULL; if ((locale_name = setlocale(LC_ALL, "")) && strcmp(locale_name, "C")) am_str = nl_langinfo(AM_STR); format = (am_str && *am_str) ? "%l:%M %p" : "%H:%M"; time(&now); tp = localtime(&now); strftime(tm_str, sizeof(tm_str), format, tp); puts(tm_str); return 0; } Hope that helps, Steve.
Further to my last message both date(1) and strftime(3) support %X which appears to do the right thing provided the locale concerned has been built. If not it defaults to 24 hour clock.
Reported as https://launchpad.net/distros/ubuntu/+source/evolution/+bug/35602 as well.
I would use for this a more general bug report, thus marking as a duplicate. *** This bug has been marked as a duplicate of 205137 ***