186 lines
5.3 KiB
C#
186 lines
5.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Globalization;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace System
|
|
{
|
|
// Token: 0x020006B2 RID: 1714
|
|
[Serializable]
|
|
internal class CurrentSystemTimeZone : TimeZone, IDeserializationCallback
|
|
{
|
|
// Token: 0x060040EC RID: 16620 RVA: 0x000DD114 File Offset: 0x000DB314
|
|
internal CurrentSystemTimeZone()
|
|
{
|
|
}
|
|
|
|
// Token: 0x060040ED RID: 16621 RVA: 0x000DD128 File Offset: 0x000DB328
|
|
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);
|
|
}
|
|
|
|
// Token: 0x060040EE RID: 16622 RVA: 0x000DD1C0 File Offset: 0x000DB3C0
|
|
void IDeserializationCallback.OnDeserialization(object sender)
|
|
{
|
|
this.OnDeserialization(null);
|
|
}
|
|
|
|
// Token: 0x060040EF RID: 16623
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern bool GetTimeZoneData(int year, out long[] data, out string[] names);
|
|
|
|
// Token: 0x17000BFD RID: 3069
|
|
// (get) Token: 0x060040F0 RID: 16624 RVA: 0x000DD1CC File Offset: 0x000DB3CC
|
|
public override string DaylightName
|
|
{
|
|
get
|
|
{
|
|
return this.m_daylightName;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000BFE RID: 3070
|
|
// (get) Token: 0x060040F1 RID: 16625 RVA: 0x000DD1D4 File Offset: 0x000DB3D4
|
|
public override string StandardName
|
|
{
|
|
get
|
|
{
|
|
return this.m_standardName;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060040F2 RID: 16626 RVA: 0x000DD1DC File Offset: 0x000DB3DC
|
|
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 daylightTime2;
|
|
lock (cachedDaylightChanges)
|
|
{
|
|
DaylightTime daylightTime = (DaylightTime)this.m_CachedDaylightChanges[year];
|
|
if (daylightTime == null)
|
|
{
|
|
long[] array;
|
|
string[] array2;
|
|
if (!CurrentSystemTimeZone.GetTimeZoneData(year, out array, out array2))
|
|
{
|
|
throw new ArgumentException(Locale.GetText("Can't get timezone data for " + year));
|
|
}
|
|
daylightTime = this.GetDaylightTimeFromData(array);
|
|
this.m_CachedDaylightChanges.Add(year, daylightTime);
|
|
}
|
|
daylightTime2 = daylightTime;
|
|
}
|
|
return daylightTime2;
|
|
}
|
|
|
|
// Token: 0x060040F3 RID: 16627 RVA: 0x000DD2CC File Offset: 0x000DB4CC
|
|
public override TimeSpan GetUtcOffset(DateTime time)
|
|
{
|
|
if (this.IsDaylightSavingTime(time))
|
|
{
|
|
return this.utcOffsetWithDLS;
|
|
}
|
|
return this.utcOffsetWithOutDLS;
|
|
}
|
|
|
|
// Token: 0x060040F4 RID: 16628 RVA: 0x000DD2E8 File Offset: 0x000DB4E8
|
|
private void OnDeserialization(DaylightTime dlt)
|
|
{
|
|
if (dlt == null)
|
|
{
|
|
CurrentSystemTimeZone.this_year = DateTime.Now.Year;
|
|
long[] array;
|
|
string[] array2;
|
|
if (!CurrentSystemTimeZone.GetTimeZoneData(CurrentSystemTimeZone.this_year, out array, out array2))
|
|
{
|
|
throw new ArgumentException(Locale.GetText("Can't get timezone data for " + CurrentSystemTimeZone.this_year));
|
|
}
|
|
dlt = this.GetDaylightTimeFromData(array);
|
|
}
|
|
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;
|
|
}
|
|
|
|
// Token: 0x060040F5 RID: 16629 RVA: 0x000DD398 File Offset: 0x000DB598
|
|
private DaylightTime GetDaylightTimeFromData(long[] data)
|
|
{
|
|
return new DaylightTime(new DateTime(data[0]), new DateTime(data[1]), new TimeSpan(data[3]));
|
|
}
|
|
|
|
// Token: 0x040019F2 RID: 6642
|
|
private string m_standardName;
|
|
|
|
// Token: 0x040019F3 RID: 6643
|
|
private string m_daylightName;
|
|
|
|
// Token: 0x040019F4 RID: 6644
|
|
private Hashtable m_CachedDaylightChanges = new Hashtable(1);
|
|
|
|
// Token: 0x040019F5 RID: 6645
|
|
private long m_ticksOffset;
|
|
|
|
// Token: 0x040019F6 RID: 6646
|
|
[NonSerialized]
|
|
private TimeSpan utcOffsetWithOutDLS;
|
|
|
|
// Token: 0x040019F7 RID: 6647
|
|
[NonSerialized]
|
|
private TimeSpan utcOffsetWithDLS;
|
|
|
|
// Token: 0x040019F8 RID: 6648
|
|
private static int this_year;
|
|
|
|
// Token: 0x040019F9 RID: 6649
|
|
private static DaylightTime this_year_dlt;
|
|
|
|
// Token: 0x020006B3 RID: 1715
|
|
internal enum TimeZoneData
|
|
{
|
|
// Token: 0x040019FB RID: 6651
|
|
DaylightSavingStartIdx,
|
|
// Token: 0x040019FC RID: 6652
|
|
DaylightSavingEndIdx,
|
|
// Token: 0x040019FD RID: 6653
|
|
UtcOffsetIdx,
|
|
// Token: 0x040019FE RID: 6654
|
|
AdditionalDaylightOffsetIdx
|
|
}
|
|
|
|
// Token: 0x020006B4 RID: 1716
|
|
internal enum TimeZoneNames
|
|
{
|
|
// Token: 0x04001A00 RID: 6656
|
|
StandardNameIdx,
|
|
// Token: 0x04001A01 RID: 6657
|
|
DaylightNameIdx
|
|
}
|
|
}
|
|
}
|