telepathyClient: Only use 12-hour format when supported by the locale

It is a bit odd to request AM/PM format when the locale selected
by LC_TIME lacks the concept. We ignore the format setting in that
case elsewhere and assume 24-hour format, let's do the same for
chat timestamps for consistency.

https://bugzilla.gnome.org/show_bug.cgi?id=728271
This commit is contained in:
Florian Müllner 2014-04-03 17:16:48 +02:00
parent df1bed941d
commit b8f0d0f0dc

View File

@ -948,9 +948,9 @@ const ChatNotification = new Lang.Class({
let desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' }); let desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
let clockFormat = desktopSettings.get_string(CLOCK_FORMAT_KEY); let clockFormat = desktopSettings.get_string(CLOCK_FORMAT_KEY);
let hasAmPm = date.toLocaleFormat('%p') != '';
switch (clockFormat) { if (clockFormat == '24h' || !hasAmPm) {
case '24h':
// Show only the time if date is on today // Show only the time if date is on today
if(daysAgo < 1){ if(daysAgo < 1){
/* Translators: Time in 24h format */ /* Translators: Time in 24h format */
@ -983,10 +983,7 @@ const ChatNotification = new Lang.Class({
// xgettext:no-c-format // xgettext:no-c-format
format = _("%B %d %Y, %H\u2236%M"); format = _("%B %d %Y, %H\u2236%M");
} }
break; } else {
default:
/* explicit fall-through */
case '12h':
// Show only the time if date is on today // Show only the time if date is on today
if(daysAgo < 1){ if(daysAgo < 1){
/* Translators: Time in 24h format */ /* Translators: Time in 24h format */
@ -1019,7 +1016,6 @@ const ChatNotification = new Lang.Class({
// xgettext:no-c-format // xgettext:no-c-format
format = _("%B %d %Y, %l\u2236%M %p"); format = _("%B %d %Y, %l\u2236%M %p");
} }
break;
} }
return date.toLocaleFormat(format); return date.toLocaleFormat(format);
}, },