// Token: 0x060016F1 RID: 5873 RVA: 0x0006C77C File Offset: 0x0006A97C private static bool TryParseDateMicrosoft(string text, Class_320 dateParseHandling, Class_321 dateTimeZoneHandling, out object dt) { string text2 = text.Substring(6, text.Length - 8); DateTimeKind dateTimeKind = DateTimeKind.Utc; int num = text2.IndexOf('+', 1); if (num == -1) { num = text2.IndexOf('-', 1); } TimeSpan timeSpan = TimeSpan.Zero; if (num != -1) { dateTimeKind = DateTimeKind.Local; timeSpan = Class_502.ReadOffset(text2.Substring(num)); text2 = text2.Substring(0, num); } long javaScriptTicks; if (!long.TryParse(text2, NumberStyles.Integer, CultureInfo.InvariantCulture, out javaScriptTicks)) { dt = null; return(false); } DateTime dateTime = Class_502.ConvertJavaScriptTicksToDateTime(javaScriptTicks); if (dateParseHandling == Class_320.DateTimeOffset) { dt = new DateTimeOffset(dateTime.Add(timeSpan).Ticks, timeSpan); return(true); } DateTime value; switch (dateTimeKind) { case DateTimeKind.Unspecified: value = DateTime.SpecifyKind(dateTime.ToLocalTime(), DateTimeKind.Unspecified); goto IL_DB; case DateTimeKind.Local: value = dateTime.ToLocalTime(); goto IL_DB; } value = dateTime; IL_DB: dt = Class_502.EnsureDateTime(value, dateTimeZoneHandling); return(true); }
// Token: 0x060016F2 RID: 5874 RVA: 0x0006C874 File Offset: 0x0006AA74 private static bool TryParseDateExact(string text, Class_320 dateParseHandling, Class_321 dateTimeZoneHandling, string dateFormatString, CultureInfo culture, out object dt) { DateTime dateTime; if (dateParseHandling == Class_320.DateTimeOffset) { DateTimeOffset dateTimeOffset; if (DateTimeOffset.TryParseExact(text, dateFormatString, culture, DateTimeStyles.RoundtripKind, out dateTimeOffset)) { dt = dateTimeOffset; return(true); } } else if (DateTime.TryParseExact(text, dateFormatString, culture, DateTimeStyles.RoundtripKind, out dateTime)) { dateTime = Class_502.EnsureDateTime(dateTime, dateTimeZoneHandling); dt = dateTime; return(true); } dt = null; return(false); }
// Token: 0x060016F0 RID: 5872 RVA: 0x0006C6B0 File Offset: 0x0006A8B0 internal static bool TryParseDateTime(string s, Class_320 dateParseHandling, Class_321 dateTimeZoneHandling, string dateFormatString, CultureInfo culture, out object dt) { if (s.Length > 0) { if (s[0] == '/') { if (s.StartsWith("/Date(", StringComparison.Ordinal) && s.EndsWith(")/", StringComparison.Ordinal) && Class_502.TryParseDateMicrosoft(s, dateParseHandling, dateTimeZoneHandling, out dt)) { return(true); } } else if (s.Length >= 19 && s.Length <= 40 && char.IsDigit(s[0]) && s[10] == 'T' && Class_502.TryParseDateIso(s, dateParseHandling, dateTimeZoneHandling, out dt)) { return(true); } if (!string.IsNullOrEmpty(dateFormatString) && Class_502.TryParseDateExact(s, dateParseHandling, dateTimeZoneHandling, dateFormatString, culture, out dt)) { return(true); } } dt = null; return(false); }
// Token: 0x060016EF RID: 5871 RVA: 0x0006C418 File Offset: 0x0006A618 internal static bool TryParseDateIso(string text, Class_320 dateParseHandling, Class_321 dateTimeZoneHandling, out object dt) { Class_358 class_ = default(Class_358); if (!class_.Parse(text)) { dt = null; return(false); } DateTime dateTime = new DateTime(class_.Year, class_.Month, class_.Day, class_.Hour, class_.Minute, class_.Second); dateTime = dateTime.AddTicks((long)class_.Fraction); if (dateParseHandling != Class_320.DateTimeOffset) { switch (class_.Zone) { case Class_357.Utc: dateTime = new DateTime(dateTime.Ticks, DateTimeKind.Utc); break; case Class_357.LocalWestOfUtc: { TimeSpan timeSpan = new TimeSpan(class_.ZoneHour, class_.ZoneMinute, 0); long num = dateTime.Ticks + timeSpan.Ticks; if (num <= DateTime.MaxValue.Ticks) { dateTime = new DateTime(num, DateTimeKind.Utc).ToLocalTime(); } else { num += dateTime.GetUtcOffset().Ticks; if (num > DateTime.MaxValue.Ticks) { num = DateTime.MaxValue.Ticks; } dateTime = new DateTime(num, DateTimeKind.Local); } break; } case Class_357.LocalEastOfUtc: { TimeSpan timeSpan2 = new TimeSpan(class_.ZoneHour, class_.ZoneMinute, 0); long num = dateTime.Ticks - timeSpan2.Ticks; if (num >= DateTime.MinValue.Ticks) { dateTime = new DateTime(num, DateTimeKind.Utc).ToLocalTime(); } else { num += dateTime.GetUtcOffset().Ticks; if (num < DateTime.MinValue.Ticks) { num = DateTime.MinValue.Ticks; } dateTime = new DateTime(num, DateTimeKind.Local); } break; } } dt = Class_502.EnsureDateTime(dateTime, dateTimeZoneHandling); return(true); } TimeSpan utcOffset; switch (class_.Zone) { case Class_357.Utc: utcOffset = new TimeSpan(0L); break; case Class_357.LocalWestOfUtc: utcOffset = new TimeSpan(-class_.ZoneHour, -class_.ZoneMinute, 0); break; case Class_357.LocalEastOfUtc: utcOffset = new TimeSpan(class_.ZoneHour, class_.ZoneMinute, 0); break; default: utcOffset = TimeZoneInfo.Local.GetUtcOffset(dateTime); break; } long num2 = dateTime.Ticks - utcOffset.Ticks; if (num2 < 0L || num2 > 3155378975999999999L) { dt = null; return(false); } dt = new DateTimeOffset(dateTime, utcOffset); return(true); }