From 83a937294fc13c0038e54d55b0fd487860e1d01a Mon Sep 17 00:00:00 2001 From: Gavriel Fleischer Date: Sun, 4 Jul 2021 10:52:09 +0300 Subject: [PATCH 1/2] fix sunrise when it's tomorrow --- source/DataFields.mc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DataFields.mc b/source/DataFields.mc index 2f2cf216..514a347a 100644 --- a/source/DataFields.mc +++ b/source/DataFields.mc @@ -643,7 +643,7 @@ class DataFields extends Ui.Drawable { if (tomorrow) { now = now.add(new Time.Duration(24 * 60 * 60)); } - var d = Gregorian.info(Time.now(), Time.FORMAT_SHORT); + var d = Gregorian.info(now, Time.FORMAT_SHORT); var rad = Math.PI / 180.0d; var deg = 180.0d / Math.PI; From bdb5d520ca80c197516d6111295c081208e18b90 Mon Sep 17 00:00:00 2001 From: Gavriel Fleischer Date: Tue, 6 Jul 2021 01:30:04 +0300 Subject: [PATCH 2/2] add UTC / GMT as possible value for Local Time City --- source/DataArea.mc | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/source/DataArea.mc b/source/DataArea.mc index 078f07b5..b50550ed 100644 --- a/source/DataArea.mc +++ b/source/DataArea.mc @@ -88,8 +88,13 @@ class DataArea extends Ui.Drawable { ); // Time zone 1 time. - var time; - if (cityLocalTime) { + var timeZoneGmtOffset = null; + var time = "..."; + if (city.equals("UTC") || city.equals("GMT")) { + + timeZoneGmtOffset = 0; + + } else if (cityLocalTime) { // Web request responded with server error e.g. unknown city. if (cityLocalTime["error"] != null) { @@ -98,7 +103,6 @@ class DataArea extends Ui.Drawable { // Web request responded with time zone data for city. } else { - var timeZoneGmtOffset; // Use next GMT offset if it's now applicable (new data will be requested shortly). if ((cityLocalTime["next"] != null) && (Time.now().value() >= cityLocalTime["next"]["when"])) { @@ -106,21 +110,20 @@ class DataArea extends Ui.Drawable { } else { timeZoneGmtOffset = cityLocalTime["current"]["gmtOffset"]; } - timeZoneGmtOffset = new Time.Duration(timeZoneGmtOffset); - - var localGmtOffset = Sys.getClockTime().timeZoneOffset; - localGmtOffset = new Time.Duration(localGmtOffset); - - // (Local time) - (Local GMT offset) + (Time zone GMT offset) - time = Time.now().subtract(localGmtOffset).add(timeZoneGmtOffset); - time = Gregorian.info(time, Time.FORMAT_SHORT); - time = App.getApp().getFormattedTime(time.hour, time.min); - time = time[:hour] + ":" + time[:min] + time[:amPm]; } + } - // Awaiting response to web request sent by BackgroundService. - } else { - time = "..."; + if (timeZoneGmtOffset != null) { + timeZoneGmtOffset = new Time.Duration(timeZoneGmtOffset); + + var localGmtOffset = Sys.getClockTime().timeZoneOffset; + localGmtOffset = new Time.Duration(localGmtOffset); + + // (Local time) - (Local GMT offset) + (Time zone GMT offset) + time = Time.now().subtract(localGmtOffset).add(timeZoneGmtOffset); + time = Gregorian.info(time, Time.FORMAT_SHORT); + time = App.getApp().getFormattedTime(time.hour, time.min); + time = time[:hour] + ":" + time[:min] + time[:amPm]; } dc.setColor(gMonoLightColour, Gfx.COLOR_TRANSPARENT);