[polari] chatView: Use locale format for timestamps
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Use locale format for timestamps
- Date: Wed, 5 Mar 2014 16:36:59 +0000 (UTC)
commit e1516ea09287f822321c7b9ef8773819bf502fe6
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Wed Mar 5 12:30:09 2014 +0100
chatView: 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 accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=712626
src/chatView.js | 86 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 62 insertions(+), 24 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 9f11626..7e42f25 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -550,30 +550,68 @@ const ChatView = new Lang.Class({
let daysAgo = now.difference(date) / GLib.TIME_SPAN_DAY;
let format;
- // Show only the hour if date is on today
- if(daysAgo < 1){
- format = "%H:%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:%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:%M");
-
- } else if (date.get_year() == now.get_year()) {
- /* 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:%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:%M");
+ let desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
+ let clockFormat = desktopSettings.get_string('clock-format');
+
+ switch (clockFormat) {
+ case '24h':
+ if(daysAgo < 1) { // today
+ /* Translators: Time in 24h format */
+ format = _("%H\u2236%M");
+ } else if(daysAgo <2) { // yesterday
+ /* 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");
+ } else if (daysAgo < 7) { // this week
+ /* 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.get_year() == now.get_year()) { // this year
+ /* 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 { // before this year
+ /* 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':
+ if(daysAgo < 1) { // today
+ /* Translators: Time in 24h format */
+ format = _("%l\u2236%M %p");
+ } else if(daysAgo <2) { // yesterday
+ /* 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");
+ } else if (daysAgo < 7) { // this week
+ /* 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.get_year() == now.get_year()) { // this year
+ /* 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 { // before this year
+ /* 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.format(format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]