public override DaylightTime GetDaylightChanges(int year)
{
if (year < 1 || year > 9999)
{
throw new ArgumentOutOfRangeException("year", String.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), 1, 9999));
}
Object objYear = (Object)year;
if (!m_CachedDaylightChanges.Contains(objYear))
{
BCLDebug.Log("Getting TimeZone information for: " + objYear);
lock (typeof(CurrentSystemTimeZone)) {
if (!m_CachedDaylightChanges.Contains(objYear))
{
//
// rawData is an array of 17 short (16 bit) numbers.
// The first 8 numbers contains the
// year/month/day/dayOfWeek/hour/minute/second/millisecond for the starting time of daylight saving time.
// The next 8 numbers contains the
// year/month/day/dayOfWeek/hour/minute/second/millisecond for the ending time of daylight saving time.
// The last short number is the delta to the standard offset in minutes.
//
short[] rawData = nativeGetDaylightChanges();
if (rawData == null)
{
//
// If rawData is null, it means that daylight saving time is not used
// in this timezone. So keep currentDaylightChanges as the empty array.
//
m_CachedDaylightChanges.Add(objYear, new DaylightTime(DateTime.MinValue, DateTime.MinValue, TimeSpan.Zero));
}
else
{
DateTime start;
DateTime end;
TimeSpan delta;
//
// Store the start of daylight saving time.
//
start = GetDayOfWeek(year, rawData[1], rawData[2],
rawData[3],
rawData[4], rawData[5], rawData[6], rawData[7]);
//
// Store the end of daylight saving time.
//
end = GetDayOfWeek(year, rawData[9], rawData[10],
rawData[11],
rawData[12], rawData[13], rawData[14], rawData[15]);
delta = new TimeSpan(rawData[16] * TicksPerMinute);
DaylightTime currentDaylightChanges = new DaylightTime(start, end, delta);
m_CachedDaylightChanges.Add(objYear, currentDaylightChanges);
}
}
}
}
DaylightTime result = (DaylightTime)m_CachedDaylightChanges[objYear];
return(result);
}