Related Issue
Description
The documentation for Gregorian.moment() implies that the input is in local time, Gregorian.info() and utcInfo() suggest otherwise.
Hopefully I'm not missing something here.
https://developer.garmin.com/connect-iq/api-docs/Toybox/Time/Gregorian.html#moment-instance_function
moment(options) ⇒ Toybox.Time.Moment
Create a Moment from a Dictionary of options.
Unlike Moment.initialize(), which is based on the UNIX epoch, a Moment created with Gregorian.moment() is based on today(). The result is determined by taking the result of today() and overlaying the options provided.
If UTC values are desired, it is necessary to account for the local UTC offset.
Recreation Procedure
Create simple data field with following compute() method:
function compute(info) { var timeInfo = new [2]; var moment; // My timezone is Eastern Time // On June 1, the timezone offset is UTC-4 moment = Gregorian.moment({ :year => 2021, :month => 6, :day => 1, :hour => 16, :minutes => 0, :seconds => 0 }); timeInfo[0] = Gregorian.utcInfo(moment, Time.FORMAT_MEDIUM); timeInfo[1] = Gregorian.info(moment, Time.FORMAT_MEDIUM); return "UTC: " + timeInfo[0].hour + " Local: " + timeInfo[1].hour; }
Run data field in simulator and on real watch.
In my timezone (Eastern Time, which is UTC-4 during DST) the data field displays the following text:
"UTC: 16 Local: 12".
If the input to Gregorian.moment() was in fact interpreted as local time, then I would expect the data field to display:
"UTC: 20: Local: 16".
Environment
- Windows 10
- VS Code
- SDK 3.2.5
- Garmin 935 21.00