[gnome-shell] [panel] Detect clock AM/PM from locale



commit c21e692652a9516cbeff30722d1e6358bde7fe52
Author: res <resqu gmx ch>
Date:   Thu Feb 11 14:01:19 2010 -0500

    [panel] Detect clock AM/PM from locale
    
    Look at whether a localized time string from JS includes am/pm to
    determine whether we should show it in the UI.

 js/ui/panel.js |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index ac36c09..fe5fb4c 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -553,8 +553,15 @@ Panel.prototype = {
             displayDate.setMinutes(displayDate.getMinutes() + 1);
             msecRemaining += 60000;
         }
-        /* Translators: This is a time format.  */
-        this._clock.set_text(displayDate.toLocaleFormat(_("%a %l:%M %p")));
+	/* If there is no am or pm, time format is 24h */
+	let isTime24h = displayDate.toLocaleFormat("x%p") == "x";
+	if (isTime24h) {
+	  /* Translators: This is a time format.  */
+	  this._clock.set_text(displayDate.toLocaleFormat(_("%a %R")));
+	} else {
+	  /* Translators: This is a time format.  */
+	  this._clock.set_text(displayDate.toLocaleFormat(_("%a %k:%M %p")));
+	}
         Mainloop.timeout_add(msecRemaining, Lang.bind(this, this._updateClock));
         return false;
     },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]