Add setting to switch between 12 and 24 hour timestamps
authorJack Allnutt <jack@allnutt.eu>
Tue, 4 Feb 2014 23:05:01 +0000 (23:05 +0000)
committerJack Allnutt <jack@allnutt.eu>
Tue, 4 Feb 2014 23:05:01 +0000 (23:05 +0000)
Resolves #282

client/assets/themes/relaxed/style.css
client/src/applets/settings.js
client/src/index.html.tmpl
client/src/translations/en-gb.po
client/src/views/channel.js
config.example.js

index 7e9f65d0056ceb4f5fe1cd92f7e5883f83314abb..0b27d7516d6d0e68d304886c060ec570761353d6 100644 (file)
 #kiwi .messages a { text-decoration:none; }
 
 #kiwi .messages .msg { border-bottom: 1px solid #DEDEDE; padding: 1px; font-family:arial; font-size:0.9em; }
-#kiwi .messages .msg .time { width:5em; float:left; color:#777; padding:5px; display:none; }
+#kiwi .messages .msg .time { width:6em; float:left; color:#777; padding:5px; display:none; }
 #kiwi .messages .msg .nick { width:11em; float:left; font-size:12px; font-family:Arial; text-align:right; padding: 5px; overflow:hidden; }
 #kiwi .messages .msg .text { display:block; margin-left:12em; border-left: 1px solid #DEDEDE; white-space:pre-wrap; word-wrap:break-word; font-family:arial; padding:5px; }
 
 }
 
 #kiwi.timestamps .messages .msg .time { display:block; }
-#kiwi.timestamps .messages .msg .text { margin-left:17em; }
+#kiwi.timestamps .messages .msg .text { margin-left:18em; }
 
 #kiwi .messages .msg.global_nick_highlight,
 #kiwi .messages .msg.highlight { transition: background 0.3s; background:#D9D9D9; }
index e88ce10d7c2745bbc0753178fbbe75715aefe392..f041ab196506c6ba4efe2fcbed8ceb52707540e2 100644 (file)
@@ -15,6 +15,7 @@
                 join_part: _kiwi.global.i18n.translate('client_applets_settings_notification_joinpart').fetch(),\r
                 count_all_activity: _kiwi.global.i18n.translate('client_applets_settings_notification_count_all_activity').fetch(),\r
                 timestamps: _kiwi.global.i18n.translate('client_applets_settings_timestamp').fetch(),\r
+                timestamp_24: _kiwi.global.i18n.translate('client_applets_settings_timestamp_24_hour').fetch(),\r
                 mute: _kiwi.global.i18n.translate('client_applets_settings_notification_sound').fetch(),\r
                 emoticons: _kiwi.global.i18n.translate('client_applets_settings_emoticons').fetch(),\r
                 scroll_history: _kiwi.global.i18n.translate('client_applets_settings_history_length').fetch(),\r
index f0d82f5b74b04a0aa5fab55699ecce987bffd62a..49e146d6fcae474e989e8f7b737e1ab5c958195e 100644 (file)
                                 <%= timestamps %>\r
                             </label>\r
                         </div>\r
+                        <div class="checkbox">\r
+                            <label>\r
+                                <input data-setting="use_24_hour_timestamps" type="checkbox">\r
+                                <%= timestamp_24 %>\r
+                            </label>\r
+                        </div>\r
                         <div class="checkbox">\r
                             <label>\r
                                 <input data-setting="mute_sounds" type="checkbox">\r
index 5f40c209dbc2f5c79aa198c8a007ed7bac1d4957..1cfccc2606394b2a9e86ee6da625d5199769e56b 100755 (executable)
@@ -66,7 +66,11 @@ msgstr "Join/part channel notifications"
 
 #: 
 msgid "client_applets_settings_timestamp"
-msgstr "Timestamps"
+msgstr "Show timestamps"
+
+#: 
+msgid "client_applets_settings_timestamp_24_hour"
+msgstr "Use 24-hour timestamps"
 
 #: 
 msgid "client_applets_settings_notification_sound"
@@ -320,6 +324,14 @@ msgstr "Cancel"
 msgid "client_views_panel_activity"
 msgstr "People are talking!"
 
+#:
+msgid "client_views_panel_timestamp_am"
+msgstr "%s AM"
+
+#:
+msgid "client_views_panel_timestamp_pm"
+msgstr "%s PM"
+
 #: client/assets/src/views/serverselect.js
 msgid "client_views_serverselect_form_title"
 msgstr "Think of a nickname..."
index e7860bcec2e47852ce90b5638c49f52904b093c8..df9d31556e2c3b30a65f3a73029fd4cff33b17a6 100644 (file)
@@ -58,7 +58,8 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
             nick_colour_hex, nick_hex, is_highlight, msg_css_classes = '',
             time_difference,
             sb = this.model.get('scrollback'),
-            prev_msg = sb[sb.length-2];
+            prev_msg = sb[sb.length-2],
+            hour, pm;
 
         // Nick highlight detecting
         if ((new RegExp('(^|\\W)(' + escapeRegex(_kiwi.app.connections.active_connection.get('nick')) + ')(\\W|$)', 'i')).test(msg.msg)) {
@@ -139,7 +140,18 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
 
         // Build up and add the line
         msg.msg_css_classes = msg_css_classes;
-        msg.time_string = msg.time.getHours().toString().lpad(2, "0") + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0");
+        if (_kiwi.global.settings.get('use_24_hour_timestamps')) {
+            msg.time_string = msg.time.getHours().toString().lpad(2, "0") + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0");
+        } else {
+            hour = msg.time.getHours();
+            pm = hour > 11;
+            hour = (hour === 0) ? 12 : hour % 12;
+            if (pm) {
+                msg.time_string = _kiwi.global.i18n.translate('client_views_panel_timestamp_pm').fetch(hour + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0"));
+            } else {
+                msg.time_string = _kiwi.global.i18n.translate('client_views_panel_timestamp_am').fetch(hour + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0"));
+            }
+        }
         line_msg = '<div class="msg <%= type %> <%= msg_css_classes %>"><div class="time"><%- time_string %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';
         this.$messages.append(_.template(line_msg, msg));
 
index 722042ac403727d6a6bfd5b359ae735a2a6c5b96..1314152faca35ffd7e098867d91271a7372bcfea 100644 (file)
@@ -182,6 +182,7 @@ conf.client = {
         scrollback: 250,
         show_joins_parts: true,
         show_timestamps: false,
+        use_24_hour_timestamps: true,
         mute_sounds: false,
         show_emoticons: true,
         count_all_activity: true