Watch hangs up after using utcInfo()

Hi,

I am trying to calculate sunrise and sunset. In my formula I have to calculate the difference between local time and utc time. Therefore I use utcInfo() to get the utc time. Nevertheless, as soon as I use this

var temp = - Activity.getActivityInfo().currentLocation.toDegrees()[1]/15 - (Greg.utcInfo(Date.now(), Date.FORMAT_SHORT).hour - hours);


the physical watch hangs up after updating. In the simulator all works well. I tracked the problem even further down and as soon as I include this line:

var utc = Greg.utcInfo(Date.now(), Date.FORMAT_SHORT).hour;

even if I don't use the variable utc the physical watch hangs up. I tried it on my Fenix 3 HR. Do you have any hints for me or any workaround to get the time diff between utc and local time?

Thanks for supporting.
  • Hi,

    maybe just use this to get the difference to UTC.

    ...
    utcoffset = Sys.getClockTime().timeZoneOffset/3600;
    ...

    This definitely works.

    Cheers
  • Per the doc:
    Use utcInfo() to retrieve a Gregorian.Info for a date converted to UTC.

    Parameters:
    date (Moment) — Moment object to get Info from
    format (Number) — Time FORMAT_XXX constant to use
    Returns:
    (Info) — For FORMAT_SHORT, all values in Info are integers. For FORMAT_MEDIUM and FORMAT_LONG, the month/day fields have the strings for the date in question. The time returned has been converted to UTC.
    Since:
    2.0.0


    The hang was likely a crash of your watchface. the f3-hr is on 1.3 or 1.4, but you should see something in ciq_log.txt

    As suggested, use timeZoneOffset, but you probably also want to use dst (dst offset)
  • Thanks guys, that helped.

    Jim, in my algorithm, I don't need dist. I used this German website: http://lexikon.astronomie.info/zeitgleichung/

    Just lat and lon are needed.
  • If you're getting the times back from the website as "unix timestamps", there's actually an easy way to convert that to local time, without worrying about the utcOffset. Let me know if that's the case.
  • Ah, Jim, it means summer/winter time. I thought, dst has something to do with distance. Sorry for messing this up.