From a52b3f4e2ab71b80d67b02e4dfeb11aaa6f1505b Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Thu, 26 Sep 2013 18:17:37 -0700 Subject: [PATCH] Friendly dates sometimes showing incorrect form I just now received a message that Geary dated as Friday (i.e. tomorrow). It turns out some of my mail is in TZ +0000 and some -0700. When it's +0000, Geary wasn't converting into local time before displaying. The argument against doing this conversion in Imap.InternalDate is that it's holding as accurate a conversion as possible from the server's representation and the DateTime object, down to the timezone. Callers who intend to display the date should convert to local time before doing so. --- src/client/util/util-date.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/util/util-date.vala b/src/client/util/util-date.vala index f7a690f1..16d8e357 100644 --- a/src/client/util/util-date.vala +++ b/src/client/util/util-date.vala @@ -197,10 +197,11 @@ private string pretty_print_coarse(CoarseDate coarse_date, ClockFormat clock_for } public string pretty_print(DateTime datetime, ClockFormat clock_format) { + DateTime to_local = datetime.to_local(); DateTime now = new DateTime.now_local(); - TimeSpan diff = now.difference(datetime); + TimeSpan diff = now.difference(to_local); - return pretty_print_coarse(as_coarse_date(datetime, now, diff), clock_format, datetime, diff); + return pretty_print_coarse(as_coarse_date(to_local, now, diff), clock_format, to_local, diff); } public string pretty_print_verbose(DateTime datetime, ClockFormat clock_format) {