[gnome-shell] telepathyClient: Use locale format for timestamps



commit 58191ea66bc381a5e2c94ff195e1979d8eb29669
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Tue Feb 18 11:14:07 2014 +0100

    telepathyClient: Use locale format for timestamps
    
    Until now the timestamps were using 24h format.
    Check gsetting clock-format to know when
    the user is using 12h format or 24h format and
    make the timestamp acordingly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715158

 js/ui/components/telepathyClient.js |  101 ++++++++++++++++++++++++++---------
 1 files changed, 76 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/components/telepathyClient.js b/js/ui/components/telepathyClient.js
index 831e4da..814e3d9 100644
--- a/js/ui/components/telepathyClient.js
+++ b/js/ui/components/telepathyClient.js
@@ -29,6 +29,8 @@ const SCROLLBACK_HISTORY_LINES = 10;
 // See Notification._onEntryChanged
 const COMPOSING_STOP_TIMEOUT = 5;
 
+const CLOCK_FORMAT_KEY = 'clock-format';
+
 const NotificationDirection = {
     SENT: 'chat-sent',
     RECEIVED: 'chat-received'
@@ -942,32 +944,81 @@ const ChatNotification = new Lang.Class({
 
         let format;
 
-        // Show only the hour if date is on today
-        if(daysAgo < 1){
-            format = _("%H\u2236%M");
-        }
-        // Show the word "Yesterday" and time if date is on yesterday
-        else if(daysAgo <2){
-            /* Translators: this is the word "Yesterday" followed by a time string. i.e. "Yesterday, 14:30"*/
-            // xgettext:no-c-format
-            format = _("Yesterday, %H\u2236%M");
-        }
-        // Show a week day and time if date is in the last week
-        else if (daysAgo < 7) {
-            /* Translators: this is the week day name followed by a time string. i.e. "Monday, 14:30*/
-            // xgettext:no-c-format
-            format = _("%A, %H\u2236%M");
-
-        } else if (date.getYear() == now.getYear()) {
-            /* Translators: this is the month name and day number followed by a time string. i.e. "May 25, 
14:30"*/
-            // xgettext:no-c-format
-            format = _("%B %d, %H\u2236%M");
-        } else {
-            /* Translators: this is the month name, day number, year number followed by a time string. i.e. 
"May 25 2012, 14:30"*/
-            // xgettext:no-c-format
-            format = _("%B %d %Y, %H\u2236%M");
-        }
+        let desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
+        let clockFormat = desktopSettings.get_string(CLOCK_FORMAT_KEY);
 
+        switch (clockFormat) {
+            case '24h':
+                // Show only the time if date is on today
+                if(daysAgo < 1){
+                    /* Translators: Time in 24h format */
+                    format = _("%H\u2236%M");
+                }
+                // Show the word "Yesterday" and time if date is on yesterday
+                else if(daysAgo <2){
+                    /* Translators: this is the word "Yesterday" followed by a
+                     time string in 24h format. i.e. "Yesterday, 14:30" */
+                    // xgettext:no-c-format
+                    format = _("Yesterday, %H\u2236%M");
+                }
+                // Show a week day and time if date is in the last week
+                else if (daysAgo < 7) {
+                    /* Translators: this is the week day name followed by a time
+                     string in 24h format. i.e. "Monday, 14:30" */
+                    // xgettext:no-c-format
+                    format = _("%A, %H\u2236%M");
+
+                } else if (date.getYear() == now.getYear()) {
+                    /* Translators: this is the month name and day number
+                     followed by a time string in 24h format.
+                     i.e. "May 25, 14:30" */
+                    // xgettext:no-c-format
+                    format = _("%B %d, %H\u2236%M");
+                } else {
+                    /* Translators: this is the month name, day number, year
+                     number followed by a time string in 24h format.
+                     i.e. "May 25 2012, 14:30" */
+                    // xgettext:no-c-format
+                    format = _("%B %d %Y, %H\u2236%M");
+                }
+                break;
+        default:
+            /* explicit fall-through */
+            case '12h':
+                // Show only the time if date is on today
+                if(daysAgo < 1){
+                    /* Translators: Time in 24h format */
+                    format = _("%l\u2236%M %p");
+                }
+                // Show the word "Yesterday" and time if date is on yesterday
+                else if(daysAgo <2){
+                    /* Translators: this is the word "Yesterday" followed by a
+                     time string in 12h format. i.e. "Yesterday, 2:30 pm" */
+                    // xgettext:no-c-format
+                    format = _("Yesterday, %l\u2236%M %p");
+                }
+                // Show a week day and time if date is in the last week
+                else if (daysAgo < 7) {
+                    /* Translators: this is the week day name followed by a time
+                     string in 12h format. i.e. "Monday, 2:30 pm" */
+                    // xgettext:no-c-format
+                    format = _("%A, %l\u2236%M %p");
+
+                } else if (date.getYear() == now.getYear()) {
+                    /* Translators: this is the month name and day number
+                     followed by a time string in 12h format.
+                     i.e. "May 25, 2:30 pm" */
+                    // xgettext:no-c-format
+                    format = _("%B %d, %l\u2236%M %p");
+                } else {
+                    /* Translators: this is the month name, day number, year
+                     number followed by a time string in 12h format.
+                     i.e. "May 25 2012, 2:30 pm"*/
+                    // xgettext:no-c-format
+                    format = _("%B %d %Y, %l\u2236%M %p");
+                }
+                break;
+        }
         return date.toLocaleFormat(format);
     },
 


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