[polari] chatview: fix timestamp formatting
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatview: fix timestamp formatting
- Date: Wed, 2 Jul 2014 15:21:29 +0000 (UTC)
commit e483304f461302f40ece1b0c1573baee2f6844c4
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Wed Jul 2 11:39:10 2014 +0200
chatview: fix timestamp formatting
We want to show "yesterday" when the day part of the date is
different, even if less than 24 hours have passed. To do so,
instead of computing the difference between the actual time
points, use two reference points (located at 00:01) in the
same day, that thus will be always different by an integer
number of days.
https://bugzilla.gnome.org/show_bug.cgi?id=732611
src/chatView.js | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 2db075c..e821baa 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -559,7 +559,16 @@ const ChatView = new Lang.Class({
let date = GLib.DateTime.new_from_unix_local(timestamp);
let now = GLib.DateTime.new_now_local();
- let daysAgo = now.difference(date) / GLib.TIME_SPAN_DAY;
+ // 00:01 actually, just to be safe
+ let todayMidnight = GLib.DateTime.new_local(now.get_year(),
+ now.get_month(),
+ now.get_day_of_month(),
+ 0, 1, 0);
+ let dateMidnight = GLib.DateTime.new_local(date.get_year(),
+ date.get_month(),
+ date.get_day_of_month(),
+ 0, 1, 0);
+ let daysAgo = todayMidnight.difference(dateMidnight) / GLib.TIME_SPAN_DAY;
let format;
let desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]