[DateTime] App Settings date picker in GCM iOS does not set the correct time

Environment:
  • iOS Garmin Connect Mobile app
  • All Garmin Connect IQ compatible devices
  • Bug exists since CIQ SDK 1.2.0 release


Detailed Description:

The date picker in app settings in the iOS Garmin Connect Mobile (GCM) app does not set the correct time.
Picking a date in app settings and then saving it to the device results in an epoch that has either a 5 or 6 hour offset (this depends on the United States (US) DST period).

Instead of saving an epoch value 1491004800 that corresponds to a date and time of

1 April 2017 00:00 (UTC)

it saves an incorrect epoch value 1491022800 that corresponds to an incorrect time of
1 April 2017 05:00 (UTC)


The time of the date picked with the iOS GCM date picker should always be midnight (00:00) UCT.

Depending on whether the chosen date falls within the US DST period or not, this offset is either 5 or 6 hours.

PLEASE NOTE:
This bug report only deals with the incorrect 5 or 6 hour offset. (For this bug report, ignore the DST difference between 5 and 6 hours)
Important is that the time should be 00:00 UTC.
The fact that US DST is incorrectly enforced by GCM iOS in South Africa (where I live), with a +2 TimeZone offset and no DST, should not be confused with this bug report.
A separate bug report deals with the incorrect US DST bug: [DateTime] App Settings date picker in GCM iOS applies US DST in non-US timezone

Steps to reproduce:
  • Create a watch face with a date property to be configured with app settings
  • Make sure to print the numerical value (epoch) of this property on the device's display
  • Use the bottom code to convert the epoch to a moment and then UTC date and time.
  • Display the UTC date and time below the epoch.
  • Upload the watch face to the store
  • Install the watch face to a device with minimum SDK version 2.1.0 (dependency on utcInfo)
  • Use GCM app on iOS to configure the settings for the watch face.
  • Pick a date and save the settings.
  • Note the epoch and UTC date and time on the screen
  • You will see that the time is offset by either 5 or 6 hours.

    Dates from 13 March 2017 to 5 November 2017 have 5 hour offset
    Dates before 13 March 2017 and after 5 November 2017 have 6 hour offset
    The DST change is in accordance to the info found here:
    (https://www.timeanddate.com/time/change/usa)


Code sample:
function onSettingsChanged(){
loadSettings();
Ui.requestUpdate();
}

function loadSettings(){
epoch = App.getApp().getProperty("Date");
moment = epoch ? new Cal.Moment(epoch) : null;
}

function momentToUtcStr(moment){
var info = Cal.utcInfo(moment, Time.FORMAT_LONG);
return Lang.format("$1$ $2$ $3$ - $4$:$5$", [info.day, info.month, info.year, info.hour, info.min.format("%02d")]);
}

Source Code available on request

5 hour offset:
[IMG2=JSON]{"data-align":"none","data-size":"full","src":"https:\/\/forums.garmin.com\/attachment.php?attachmentid=41533&d=1491355090"}[/IMG2]

6 hour offset:
[IMG2=JSON]{"data-align":"none","data-size":"full","src":"https:\/\/forums.garmin.com\/attachment.php?attachmentid=41534&d=1491355149"}[/IMG2]