summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2022-04-17 06:01:04 -0400
committercos <cos>2022-05-14 12:52:47 +0200
commita733b8cf505b079f2c86b93ee1cdb500ff74d23c (patch)
tree086b7ff6173ed28bf63e5d5719c244f8101feb12
parent4e67739c268ac401671098c6397b8ab5427d0fe6 (diff)
downloadmazarine-watch-a733b8cf505b079f2c86b93ee1cdb500ff74d23c.zip
Handle DST for the extra timezones displayed
Prior to this commit, the watchface needed to be recompiled and reinstalled a few times a year. Which was a bit of a hassle. Unreliable on the actual days when UTC offset changes, since no attempts are made at hitting the exact hour. That's good enough for me.
-rw-r--r--LICENSE2
-rw-r--r--Makefile2
-rw-r--r--manifest.xml2
-rw-r--r--source/MazarineView.mc37
4 files changed, 36 insertions, 7 deletions
diff --git a/LICENSE b/LICENSE
index 37c7f6a..a515fbd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2019 cy384, 2020 cos
+Copyright (C) 2019 cy384, 2020-2022 cos
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Makefile b/Makefile
index 852367d..51d444e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
DEVICE=vivoactive3
SDK=3.1.7
-VERSION="0.0.2"
+VERSION="0.0.3"
OUTPUT=bin/mazarine_$(VERSION).prg
MONKEY_SDK=~/CONNECTIQ
CONNIQ=$(MONKEY_SDK)/bin/connectiq
diff --git a/manifest.xml b/manifest.xml
index 5638436..abf2ea2 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -1,5 +1,5 @@
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
- <iq:application entry="MazarineApp" id="b3759b67-2fc3-41ea-8e15-a4b501e223a8" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.2.0" name="@Strings.AppName" type="watchface" version="0.0.2">
+ <iq:application entry="MazarineApp" id="b3759b67-2fc3-41ea-8e15-a4b501e223a8" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.2.0" name="@Strings.AppName" type="watchface" version="0.0.3">
<iq:products>
<iq:product id="approachs60"/>
<iq:product id="d2bravo"/>
diff --git a/source/MazarineView.mc b/source/MazarineView.mc
index d0c5228..725b5d9 100644
--- a/source/MazarineView.mc
+++ b/source/MazarineView.mc
@@ -1,6 +1,6 @@
// Mazarine
//
-// Copyright (C) 2019 cy384, 2020 cos
+// Copyright (C) 2019 cy384, 2020-2022 cos
// All rights reserved.
//
// This software may be modified and distributed under the terms
@@ -133,12 +133,41 @@ class MazarineView extends WatchUi.WatchFace {
}
function draw_timezones(dc) {
+ var today = Gregorian.info(Time.now(), Time.FORMAT_SHORT);
+ var weekday;
+ weekday = today.day_of_week - 1;
+
+ var past_first_sunday = (today.day - weekday) > 0;
+ var past_second_sunday = (today.day > 7) && (today.day - weekday > 7);
+
draw_utc_offset(dc);
draw_timezone(dc, 1, "HK", 8);
// draw_timezone(dc, 3, "ACDT", 10.5);
- draw_timezone(dc, 2, "NSW", 11);
- draw_timezone(dc, 3, "NY", -4);
- draw_timezone(dc, 4, "CA", -7);
+
+ // https://en.wikipedia.org/wiki/Time_in_Australia
+ // "first Sunday in October first Sunday in April"
+ if ((today.month > 4 && today.month < 10) ||
+ (today.month == 4 && past_first_sunday ) ||
+ (today.month == 10 && !past_first_sunday ))
+ {
+ draw_timezone(dc, 2, "NSW", 10);
+ } else {
+ draw_timezone(dc, 2, "NSW", 11);
+ }
+
+ // https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
+ // "In the U.S., daylight saving time starts on the second Sunday in
+ // March and ends on the first Sunday in November"
+ if ((today.month > 3 && today.month < 11) ||
+ (today.month == 3 && past_second_sunday ) ||
+ (today.month == 11 && !past_first_sunday ))
+ {
+ draw_timezone(dc, 3, "NY", -4);
+ draw_timezone(dc, 4, "CA", -7);
+ } else {
+ draw_timezone(dc, 3, "NY", -5);
+ draw_timezone(dc, 4, "CA", -8);
+ }
}
function draw_utc_offset(dc) {