Watchface: Dual Time Zone

Here is a Watchface I started on to teach myself Monkey C. Right now it is hard coded for the Mountain Time Zone and US DST rules.

On the list for the future:
As the API is expanded and I I hope to allow for user configuration for any home timezone and DST rules
Bluetooth, Sleep, Notification and Alarm icons
Suggestions?


I will do some more testing on the timezone and if it all continues to work right will put it up on Connect IQ is in the coming days. Special thanks to Travis Vitek for his help in understanding time and several of his past posts on all things Monkey C.

Paul

  • Former Member
    Former Member over 10 years ago
    Great work Paul, I can't wait to see your app come out for other time zones. I really can't believe Garmin hasn't put out a multi timezone watch face/app.

    benny
  • Former Member
    Former Member over 10 years ago
    My widget going to approved ;)

    I Europe is goot time today to test. We have DST change.
    I'm write DST table (2015-2019) for Europe and US&Canada, and ~40 timezones.
  • Very nice! quite a bit of coding to get all the timezones & DST settings - for my watch face, I am hoping that I can have some user input so that they can select their home time zone and then any time they leave the home zone, the watch will provide local and time at home. I have some ideas for how to do this for just the US, but would like to eventually allow for any other timezone to be selected by the user.
  • Former Member
    Former Member over 10 years ago
    I'm use this table:
    https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
    I'm think about parse thist table to an array in monkeyc and create class,function to convert ((int)unixepoc,'tz') to (moment).

    Many counties don't use dst, many use one dst table, for example all Europe and Us and Canada looks like this in my widget:

    var dsttab = [
    [ // europa cała zmienia o 1:00 wg UTC czyli Londyn o 1, Warszawa o 2, Helsinki o 3 (with out offset)
    [1427590800,1445734800], // 2015
    [1459040400,1477789200], // 2016
    [1490490000,1509238800], // 2017
    [1521939600,1540688400], // 2018
    [1553994000,1572138000] // 2019
    ],
    [ //usa i kanada - a oni zmieniają o 2:00, ale każda strefa o swojej 'drugiej' (plus offset)
    [1425780000,1446343200], // 2015
    [1457834400,1478397600], // 2016
    [1489284000,1509847200], // 2017
    [1520733600,1541296800] // 2018
    ]
    ];
  • Former Member
    Former Member over 10 years ago
    One method to 'hack system' :D

    Try this code to get localtime and second time. This 'remember' old timeoffset (but not timezone). User must run watchface, change time settings to manual and set secondary time, run watchface again, and finally set back time to automatic gps.

    [FONT=Courier New]
    var clockTime = Sys.getClockTime();
    //System.print("local: "+clockTime.hour+":"+clockTime.min+" ");
    var cur=clockTime.timeZoneOffset;
    var akt=app.getProperty(AKT); if (akt==null) {akt=0;}
    var sec=app.getProperty(SEC); if (sec==null) {sec=0;}
    //System.print(cur+" "+akt+" "+sec+" ");
    if (akt!=cur) {
    app.setProperty(AKT,cur);
    app.setProperty(SEC,akt);
    sec=akt;
    }
    var second=Time.now();
    second = second.add(new Time.Duration(sec-cur));
    second = Calendar.info(second, Time.FORMAT_SHORT);
    //System.println("secon: "+second.hour+":"+second.min);[/FONT]
  • I am working on something similar right now - the first time the app is started, it finds out what time it is and if it is in the US if it is on DST (I have not coded tests for other geographies). It then writes this data to the object store and if the watch goes out of the home timezone, it will report the current time and the time at home. This all works in the US unless you live in Arizona because they don't use DST.

    I hope to have the face submitted to the store soon - it will be based on the Steps on Face face that is in there now.

    If someone is interested in testing it out, drop me a note and I can send you a version to sideload.

    It would be nice if CQI could provide a current UST offset and DST given a geographic location provided. Then I would just have to figure out how to store the users home position and it would work globally. I have to think that in the depths of the system there is just a function.

    Paul
  • You got the right idea.  My new watch face handles all 24 standard timezones plus your local timezones without a complex table in a different way.  Check out GlobalSync.

    https://apps.garmin.com/en-US/apps/381450d5-c7c4-43dc-bc00-85fccc85c4f4