[gnome-clocks] Fix incorrect day label on Jan 1st or Jan 2nd
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Fix incorrect day label on Jan 1st or Jan 2nd
- Date: Sun, 9 Oct 2016 08:12:11 +0000 (UTC)
commit 431dcfe2b5a42c1332ea3ad832d55d6f483b50e4
Author: Jeffrey Enns <dev jeffk gmail com>
Date: Thu Dec 11 18:24:12 2014 -0800
Fix incorrect day label on Jan 1st or Jan 2nd
day_label() compares the day of the year between timezones to determine
whether it should display a "Yesterday" or "Tomorrow" label on a user's
configured world clocks. It accounts for the case where it is Dec 31st
at the user's location (variable t below) but Jan 1st at a remote
location (variable d) by performing the following check:
if (d < t) {
// If it is Dec 31st here and Jan 1st there (d = 1), then "tomorrow"
return d == 1 ? _("Tomorrow") : _("Yesterday");
But (d < t) && (d == 1) will also be true when d = 1 and t = 2. This
causes the "Tomorrow" label to be displayed on world clocks where it
is in fact still yesterday, if the user's current date is Jan 2nd.
The same thing happens when the user's current day is Jan 1st - world
clocks that should display "Tomorrow" display "Yesterday" instead.
To fix this, we can simply account for the Jan 2nd edge case when
d < t as follows:
return (d == 1 && t != 2) ? _("Tomorrow") : _("Yesterday");
and similar for the (d > t) case.
https://bugzilla.gnome.org/show_bug.cgi?id=722465
src/world.vala | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/world.vala b/src/world.vala
index 94a8048..afa2ccf 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -104,11 +104,13 @@ public class Item : Object, ContentItem {
var t = local_time.get_day_of_year ();
if (d < t) {
- // If it is Dec 31st here and Jan 1st there (d = 1), then "tomorrow"
- return d == 1 ? _("Tomorrow") : _("Yesterday");
+ // If it is Jan 1st there, and not Jan 2nd here, then it must be
+ // Dec 31st here, so return "tomorrow"
+ return (d == 1 && t != 2) ? _("Tomorrow") : _("Yesterday");
} else if (d > t) {
- // If it is Jan 1st here and Dec 31st there (t = 1), then "yesterday"
- return t == 1 ? _("Yesterday") : _("Tomorrow");
+ // If it is Jan 1st here, and not Jan 2nd there, then it must be
+ // Dec 31st there, so return "yesterday"
+ return (t == 1 && d != 2) ? _("Yesterday") : _("Tomorrow");
} else {
return null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]