static private GetUtcOffsetFromUtc ( System.DateTime time, |
||
time | System.DateTime | |
zone | ||
isDaylightSavings | System.Boolean | |
isAmbiguousLocalDst | System.Boolean | |
리턴 | System.TimeSpan |
public static DateTime FromBinary(long dateData) { long num2; if ((dateData & -9223372036854775808L) == 0L) { return(FromBinaryRaw(dateData)); } long ticks = dateData & 0x3fffffffffffffffL; if (ticks > 0x3fffff36d5964000L) { ticks -= 0x4000000000000000L; } bool isAmbiguousLocalDst = false; if (ticks < 0L) { num2 = TimeZoneInfo.Local.GetUtcOffset(MinValue, TimeZoneInfoOptions.NoThrowOnInvalidTime).Ticks; } else if (ticks > 0x2bca2875f4373fffL) { num2 = TimeZoneInfo.Local.GetUtcOffset(MaxValue, TimeZoneInfoOptions.NoThrowOnInvalidTime).Ticks; } else { DateTime time = new DateTime(ticks, DateTimeKind.Utc); bool isDaylightSavings = false; num2 = TimeZoneInfo.GetUtcOffsetFromUtc(time, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; } ticks += num2; if (ticks < 0L) { ticks += 0xc92a69c000L; } if ((ticks < 0L) || (ticks > 0x2bca2875f4373fffL)) { throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeBadBinaryData"), "dateData"); } return(new DateTime(ticks, DateTimeKind.Local, isAmbiguousLocalDst)); }
public DateTime ToLocalTime() { if (this.Kind == DateTimeKind.Local) { return(this); } bool isDaylightSavings = false; bool isAmbiguousLocalDst = false; long ticks = TimeZoneInfo.GetUtcOffsetFromUtc(this, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; long num2 = this.Ticks + ticks; if (num2 > 0x2bca2875f4373fffL) { return(new DateTime(0x2bca2875f4373fffL, DateTimeKind.Local)); } if (num2 < 0L) { return(new DateTime(0L, DateTimeKind.Local)); } return(new DateTime(num2, DateTimeKind.Local, isAmbiguousLocalDst)); }