{
cal.setWorkingDay(day, DEFAULT_WORKING_WEEK[index]);
if (cal.isWorkingDay(day) == true)
{
hours = cal.addCalendarHours(net.sf.mpxj.Day.getInstance(index + 1));
hours.addRange(new DateRange(defaultStart1, defaultEnd1));
hours.addRange(new DateRange(defaultStart2, defaultEnd2));
}
}
else
{
periodCount = MPPUtility.getShort(extData, offset + 2);
if (periodCount == 0)
{
cal.setWorkingDay(day, false);
}
else
{
cal.setWorkingDay(day, true);
hours = cal.addCalendarHours(Day.getInstance(index + 1));
for (periodIndex = 0; periodIndex < periodCount; periodIndex++)
{
start = MPPUtility.getTime(extData, offset + 8 + (periodIndex * 2));
duration = MPPUtility.getDuration(extData, offset + 16 + (periodIndex * 4));
hours.addRange(new DateRange(start, new Date(start.getTime() + duration)));
}
}
}
}
//
// Handle any exceptions
//
exceptionCount = MPPUtility.getShort(extData, 0);
if (exceptionCount != 0)
{
for (index = 0; index < exceptionCount; index++)
{
offset = 4 + (40 * 7) + (index * 44);
Date fromDate = MPPUtility.getDate(extData, offset);
Date toDate = MPPUtility.getDate(extData, offset + 2);
exception = cal.addCalendarException(fromDate, toDate);
periodCount = MPPUtility.getShort(extData, offset + 6);
if (periodCount != 0)
{
for (int exceptionPeriodIndex = 0; exceptionPeriodIndex < periodCount; exceptionPeriodIndex++)
{
start = MPPUtility.getTime(extData, offset + 12 + (exceptionPeriodIndex * 2));
duration = MPPUtility.getDuration(extData, offset + 20 + (exceptionPeriodIndex * 4));
exception.addRange(new DateRange(start, new Date(start.getTime() + duration)));
}
}
}
}
}