isInSchedule() evaluates one second off when user profile and schedule timezones do not match



The isInSchedule API can evaluate differently depending on the configuration of the schedule and the current user-session.

The different behavior occurs only when checking if the end time is in the schedule, where the time is on the hour, such as 19:00:00.

This behavior is noticed when the session's time zone matches the time zone of the schedule. 


Steps to Reproduce

Create a schedule defined in the US/Eastern time zone, with a single span that starts at 17:00:00 and ends at 19:00:00 repeating daily.

The script below is the test case that can be executed in Background Scripts:

    // Provide UTC value of 19:00:00 US/Eastern
    var endTime = new GlideDateTime("2017-06-21 23:00:00");

    // Provide the sys_id of the US/Eastern schedule
    var schedule = new GlideSchedule("SYS_ID_SCHEDULE");

    gs.print( schedule.isInSchedule(endTime) );

If current user-session time zone is US/Eastern the above script prints true.

If current user-session time zone is not US/Eastern the above script prints false.


For an end time on the hour to be excluded, the schedule entries end date time must be *:59:59. For example, 18:59:59 instead of 19:00:00.

The isInSchedule API returns true when checking if 18:59:59 is in the schedule but false when checking if 19:00:00 is in the schedule.

Related Problem: PRB1057795