public override DaylightTime GetDaylightChanges(int year) { if (year < 1 || year > 9999) { throw new ArgumentOutOfRangeException("year", Environment.GetResourceString("ArgumentOutOfRange_Range", (object)1, (object)9999)); } object key = (object)year; if (!this.m_CachedDaylightChanges.Contains(key)) { lock (CurrentSystemTimeZone.InternalSyncObject) { if (!this.m_CachedDaylightChanges.Contains(key)) { short[] local_3 = CurrentSystemTimeZone.nativeGetDaylightChanges(year); if (local_3 == null) { this.m_CachedDaylightChanges.Add(key, (object)new DaylightTime(DateTime.MinValue, DateTime.MinValue, TimeSpan.Zero)); } else { DateTime temp_65 = CurrentSystemTimeZone.GetDayOfWeek(year, (uint)local_3[0] > 0U, (int)local_3[1], (int)local_3[2], (int)local_3[3], (int)local_3[4], (int)local_3[5], (int)local_3[6], (int)local_3[7]); DateTime local_4 = CurrentSystemTimeZone.GetDayOfWeek(year, (uint)local_3[8] > 0U, (int)local_3[9], (int)local_3[10], (int)local_3[11], (int)local_3[12], (int)local_3[13], (int)local_3[14], (int)local_3[15]); TimeSpan local_5 = new TimeSpan((long)local_3[16] * 600000000L); DateTime temp_102 = local_4; TimeSpan temp_103 = local_5; DaylightTime local_6 = new DaylightTime(temp_65, temp_102, temp_103); this.m_CachedDaylightChanges.Add(key, (object)local_6); } } } } return((DaylightTime)this.m_CachedDaylightChanges[key]); }
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; }
public override DaylightTime GetDaylightChanges(int year) { if (year < 1 || year > 9999) { throw new ArgumentOutOfRangeException("year", Environment.GetResourceString("ArgumentOutOfRange_Range", new object[] { 1, 9999 })); } object key = year; if (!this.m_CachedDaylightChanges.Contains(key)) { object internalSyncObject = CurrentSystemTimeZone.InternalSyncObject; lock (internalSyncObject) { if (!this.m_CachedDaylightChanges.Contains(key)) { short[] array = CurrentSystemTimeZone.nativeGetDaylightChanges(year); if (array == null) { this.m_CachedDaylightChanges.Add(key, new DaylightTime(DateTime.MinValue, DateTime.MinValue, TimeSpan.Zero)); } else { DateTime dayOfWeek = CurrentSystemTimeZone.GetDayOfWeek(year, array[0] != 0, (int)array[1], (int)array[2], (int)array[3], (int)array[4], (int)array[5], (int)array[6], (int)array[7]); DateTime dayOfWeek2 = CurrentSystemTimeZone.GetDayOfWeek(year, array[8] != 0, (int)array[9], (int)array[10], (int)array[11], (int)array[12], (int)array[13], (int)array[14], (int)array[15]); TimeSpan delta = new TimeSpan((long)array[16] * 600000000L); DaylightTime value = new DaylightTime(dayOfWeek, dayOfWeek2, delta); this.m_CachedDaylightChanges.Add(key, value); } } } } return((DaylightTime)this.m_CachedDaylightChanges[key]); }
internal CurrentSystemTimeZone() { this.m_ticksOffset = (long)CurrentSystemTimeZone.nativeGetTimeZoneMinuteOffset() * 600000000L; this.m_standardName = null; this.m_daylightName = null; }
protected sealed override DaylightTime Factory(int key) => CurrentSystemTimeZone.CreateDaylightChanges(key);