Details
Description
This Friday morning our production system stopped at 00:30:00, rather than tomorrow, Saturday at 00:30:00, which caused a lot of trouble.
We have changed the time zone of our session scheduling in the production system from GMT to America/Chicago to switch correctly for the US Daylight saving later this year. We have adjusted the start end end time accordingly to accomodate the new time zone. The setting is the following now:
TZ=America/Chicago
End Day=Friday
End Time=19:30:00
This equates to the same settings in GMT, which we had previously:
End Day=Saturday
End Time=00:30:00
So QF should have shut down tomorrow morning and not today on Friday morning.
I've had a look into the QF source code and found that the start and end time do not wrap the day when the TZ offset is applied, because schedule days and times are treated separately.
The result is that if the start or end time in the target timezone is not on the same day than on GMT then QF gets it wrong.
I have done the following temporary fix to correct this:
SessionSchedule::SessionSchedule(...)
{
...
Calendar localTime = SystemTime.getUtcCalendar();
localTime.setTimeZone(sessionTimeZone);
localTime.set(Calendar.MILLISECOND, 0);
localTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(matcher.group(1)));
localTime.set(Calendar.MINUTE, Integer.parseInt(matcher.group(2)));
localTime.set(Calendar.SECOND, Integer.parseInt(matcher.group(3)));
< //moved down: Calendar startTime = SystemTime.getUtcCalendar();
< //moved down: startTime.setTime(localTime.getTime());
int startDay = -1;
if (weeklySession)
> Calendar startTime = SystemTime.getUtcCalendar();
> startTime.setTime(localTime.getTime());
matcher = TIME_PATTERN.matcher(endTimeString);
if (!matcher.find())
localTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(matcher.group(1)));
localTime.set(Calendar.MINUTE, Integer.parseInt(matcher.group(2)));
localTime.set(Calendar.SECOND, Integer.parseInt(matcher.group(3)));
< //moved down :Calendar endTime = SystemTime.getUtcCalendar();
< //moved down :endTime.setTime(localTime.getTime());
int endDay = -1;
if (weeklySession)
> Calendar endTime = SystemTime.getUtcCalendar();
> endTime.setTime(localTime.getTime());
- this.startTime = new TimeEndPoint(startTime); //removed weekday parameter
- this.endTime = new TimeEndPoint(endTime); //removed weekday parameter
}
- TimeEndPoint::TimeEndPoint(Calendar c) //removed weekday parameter { * this( c.get(Calendar.DAY_OF_WEEK) , c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND)); //use calendar's weekday instead of separate weekday }