Пример #1
0
        private async Task InitDeviceTime()
        {
            // not sure why the band doesn't report timezone in a standard way, but the time returned by
            // the band is in UTC (as per the function name) while the timeZone is a collection of properties
            // with the actual time zone represented as a raw string...
            var timeZone = await _client.GetDeviceTimeZoneAsync();

            var time = await _client.GetDeviceUtcTimeAsync();

            // ... luckily we have the "ZoneOffsetMinutes" property which can be used to offset the time to the correct time that is displayed on the band.
            time = time.AddMinutes(timeZone.ZoneOffsetMinutes);

            DeviceTime = time;

            // start a timer to update the current time (we cheat by using a local timer
            // instead of polling the device)
            _timeUpdater          = new System.Timers.Timer();
            _timeUpdater.Elapsed += _timeUpdater_Elapsed;
            _timeUpdater.Interval = (60 - time.Second) * 1000;
            _timeUpdater.Start();
        }