public override DaylightTime GetDaylightChanges(int year) { if (year < 1 || year > 9999) { throw new ArgumentOutOfRangeException("year", year + Locale.GetText(" is not in a range between 1 and 9999.")); } if (year == CurrentSystemTimeZone.this_year) { return(CurrentSystemTimeZone.this_year_dlt); } Hashtable cachedDaylightChanges = this.m_CachedDaylightChanges; DaylightTime result; lock (cachedDaylightChanges) { DaylightTime daylightTime = (DaylightTime)this.m_CachedDaylightChanges[year]; if (daylightTime == null) { long[] data; string[] array; if (!CurrentSystemTimeZone.GetTimeZoneData(year, out data, out array)) { throw new ArgumentException(Locale.GetText("Can't get timezone data for " + year)); } daylightTime = this.GetDaylightTimeFromData(data); this.m_CachedDaylightChanges.Add(year, daylightTime); } result = daylightTime; } return(result); }
internal CurrentSystemTimeZone(long lnow) { DateTime dateTime = new DateTime(lnow); long[] array; string[] array2; if (!CurrentSystemTimeZone.GetTimeZoneData(dateTime.Year, out array, out array2)) { throw new NotSupportedException(Locale.GetText("Can't get timezone name.")); } this.m_standardName = Locale.GetText(array2[0]); this.m_daylightName = Locale.GetText(array2[1]); this.m_ticksOffset = array[2]; DaylightTime daylightTimeFromData = this.GetDaylightTimeFromData(array); this.m_CachedDaylightChanges.Add(dateTime.Year, daylightTimeFromData); this.OnDeserialization(daylightTimeFromData); }
private void OnDeserialization(DaylightTime dlt) { if (dlt == null) { CurrentSystemTimeZone.this_year = DateTime.Now.Year; long[] data; string[] array; if (!CurrentSystemTimeZone.GetTimeZoneData(CurrentSystemTimeZone.this_year, out data, out array)) { throw new ArgumentException(Locale.GetText("Can't get timezone data for " + CurrentSystemTimeZone.this_year)); } dlt = this.GetDaylightTimeFromData(data); } else { CurrentSystemTimeZone.this_year = dlt.Start.Year; } this.utcOffsetWithOutDLS = new TimeSpan(this.m_ticksOffset); this.utcOffsetWithDLS = new TimeSpan(this.m_ticksOffset + dlt.Delta.Ticks); CurrentSystemTimeZone.this_year_dlt = dlt; }