using System; using System.Globalization; using System.Runtime.InteropServices; namespace System { /// Represents a time zone. /// 1 // Token: 0x020006B1 RID: 1713 [ComVisible(true)] [Serializable] public abstract class TimeZone { /// Gets the time zone of the current computer. /// A object that represents the current local time zone. /// 1 // Token: 0x17000BFA RID: 3066 // (get) Token: 0x060040E1 RID: 16609 RVA: 0x000DCCF4 File Offset: 0x000DAEF4 public static TimeZone CurrentTimeZone { get { long now = DateTime.GetNow(); object obj = TimeZone.tz_lock; TimeZone timeZone; lock (obj) { if (TimeZone.currentTimeZone == null || now - TimeZone.timezone_check > 600000000L) { TimeZone.currentTimeZone = new CurrentSystemTimeZone(now); TimeZone.timezone_check = now; } timeZone = TimeZone.currentTimeZone; } return timeZone; } } /// Gets the daylight saving time zone name. /// The daylight saving time zone name. /// 2 // Token: 0x17000BFB RID: 3067 // (get) Token: 0x060040E2 RID: 16610 public abstract string DaylightName { get; } /// Gets the standard time zone name. /// The standard time zone name. /// An attempt was made to set this property to null. /// 2 // Token: 0x17000BFC RID: 3068 // (get) Token: 0x060040E3 RID: 16611 public abstract string StandardName { get; } /// Returns the daylight saving time period for a particular year. /// A object that contains the start and end date for daylight saving time in . /// The year that the daylight saving time period applies to. /// /// is less than 1 or greater than 9999. /// 2 // Token: 0x060040E4 RID: 16612 public abstract DaylightTime GetDaylightChanges(int year); /// Returns the Coordinated Universal Time (UTC) offset for the specified local time. /// The Coordinated Universal Time (UTC) offset from . /// A date and time value. /// 2 // Token: 0x060040E5 RID: 16613 public abstract TimeSpan GetUtcOffset(DateTime time); /// Returns a value indicating whether the specified date and time is within a daylight saving time period. /// true if is in a daylight saving time period; otherwise, false. /// A date and time. /// 2 // Token: 0x060040E6 RID: 16614 RVA: 0x000DCD70 File Offset: 0x000DAF70 public virtual bool IsDaylightSavingTime(DateTime time) { return TimeZone.IsDaylightSavingTime(time, this.GetDaylightChanges(time.Year)); } /// Returns a value indicating whether the specified date and time is within the specified daylight saving time period. /// true if is in ; otherwise, false. /// A date and time. /// A daylight saving time period. /// /// is null. /// 1 // Token: 0x060040E7 RID: 16615 RVA: 0x000DCD88 File Offset: 0x000DAF88 public static bool IsDaylightSavingTime(DateTime time, DaylightTime daylightTimes) { if (daylightTimes == null) { throw new ArgumentNullException("daylightTimes"); } if (daylightTimes.Start.Ticks == daylightTimes.End.Ticks) { return false; } if (daylightTimes.Start.Ticks < daylightTimes.End.Ticks) { if (daylightTimes.Start.Ticks < time.Ticks && daylightTimes.End.Ticks > time.Ticks) { return true; } } else if (time.Year == daylightTimes.Start.Year && time.Year == daylightTimes.End.Year && (time.Ticks < daylightTimes.End.Ticks || time.Ticks > daylightTimes.Start.Ticks)) { return true; } return false; } /// Returns the local time that corresponds to a specified date and time value. /// A object whose value is the local time that corresponds to . /// A Coordinated Universal Time (UTC) time. /// 2 // Token: 0x060040E8 RID: 16616 RVA: 0x000DCE98 File Offset: 0x000DB098 public virtual DateTime ToLocalTime(DateTime time) { if (time.Kind == DateTimeKind.Local) { return time; } TimeSpan utcOffset = this.GetUtcOffset(time); if (utcOffset.Ticks > 0L) { if (DateTime.MaxValue - utcOffset < time) { return DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Local); } } else if (utcOffset.Ticks < 0L && time.Ticks + utcOffset.Ticks < DateTime.MinValue.Ticks) { return DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Local); } DateTime dateTime = time.Add(utcOffset); DaylightTime daylightChanges = this.GetDaylightChanges(time.Year); if (daylightChanges.Delta.Ticks == 0L) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Local); } if (dateTime < daylightChanges.End && daylightChanges.End.Subtract(daylightChanges.Delta) <= dateTime) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Local); } TimeSpan utcOffset2 = this.GetUtcOffset(dateTime); return DateTime.SpecifyKind(time.Add(utcOffset2), DateTimeKind.Local); } /// Returns the Coordinated Universal Time (UTC) that corresponds to a specified time. /// A object whose value is the Coordinated Universal Time (UTC) that corresponds to . /// A date and time. /// 2 // Token: 0x060040E9 RID: 16617 RVA: 0x000DCFB0 File Offset: 0x000DB1B0 public virtual DateTime ToUniversalTime(DateTime time) { if (time.Kind == DateTimeKind.Utc) { return time; } TimeSpan utcOffset = this.GetUtcOffset(time); if (utcOffset.Ticks < 0L) { if (DateTime.MaxValue + utcOffset < time) { return DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc); } } else if (utcOffset.Ticks > 0L && DateTime.MinValue + utcOffset > time) { return DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc); } return DateTime.SpecifyKind(new DateTime(time.Ticks - utcOffset.Ticks), DateTimeKind.Utc); } // Token: 0x060040EA RID: 16618 RVA: 0x000DD054 File Offset: 0x000DB254 internal TimeSpan GetLocalTimeDiff(DateTime time) { return this.GetLocalTimeDiff(time, this.GetUtcOffset(time)); } // Token: 0x060040EB RID: 16619 RVA: 0x000DD064 File Offset: 0x000DB264 internal TimeSpan GetLocalTimeDiff(DateTime time, TimeSpan utc_offset) { DaylightTime daylightChanges = this.GetDaylightChanges(time.Year); if (daylightChanges.Delta.Ticks == 0L) { return utc_offset; } DateTime dateTime = time.Add(utc_offset); if (dateTime < daylightChanges.End && daylightChanges.End.Subtract(daylightChanges.Delta) <= dateTime) { return utc_offset; } if (dateTime >= daylightChanges.Start && daylightChanges.Start.Add(daylightChanges.Delta) > dateTime) { return utc_offset - daylightChanges.Delta; } return this.GetUtcOffset(dateTime); } // Token: 0x040019EF RID: 6639 private static TimeZone currentTimeZone; // Token: 0x040019F0 RID: 6640 [NonSerialized] private static object tz_lock = new object(); // Token: 0x040019F1 RID: 6641 [NonSerialized] private static long timezone_check; } }