Sys.getClockTime() never provides a value for dst

The Sys.getClockTime() appears to correctly return time information for the local time zone, but it doesn't fill in the ClockTime.dst field as advertised. It would be nice if this field were filled in or if it were moved somewhere more appropriate.

The following test code shows the dst offset value is null, and then uses the Time module to determine the correct offset value. Since the documentation doesn't seem to indicate, I've arbitrarily decided that ClockTime.dst is the number of seconds west of UTC for use in my code.

function main()
{
var now = Sys.getClockTime();
Sys.println("now.hour=" + now.hour);
Sys.println("now.min=" + now.min);
Sys.println("now.sec=" + now.sec);
Sys.println("now.dst=" + now.dst);

// figure out the dst offset because it isn't provided
var local_now = Time.now();
var localtime = Gregorian.info(local_now, Time.FORMAT_SHORT);

var coord_now = Gregorian.momentNative(localtime.year,
localtime.month,
localtime.day,
localtime.hour,
localtime.min,
localtime.sec);

// determine the dst offset as minutes west of coordinated time
now.dst = coord_now.subtract(local_now).value();

Sys.println("now.hour=" + now.hour);
Sys.println("now.min=" + now.min);
Sys.println("now.sec=" + now.sec);
Sys.println("now.dst=" + now.dst);
}
  • Perhaps I'm interpreting the documentation incorrectly here. The docs describe the field is the Daylight savings time offset. In my code above, I'm calculating the UTC offset which is the sum of the UTC offset and the DST offset.

    If my original interpretation is wrong, I apologize for that, but it would be nice for the value to be filled in with a value and a bit more detail of what the value is in the documentation. i.e., Is it just an indicator (similar to tm::tm_isdst in C/C++, or is it the number of hours/minutes/seconds offset from standard time?

    Travis
  • In preview 2 we are adding a field in ClockTimer named timeZoneOffset which gives the number of seconds from UTC the current time is. Long term I think we will probably remove the DST flag, as I'm not sure it adds a lot of utility.

    -AlphaMonkey