// Token: 0x060016F6 RID: 5878 RVA: 0x0006CAE8 File Offset: 0x0006ACE8 internal static int WriteDefaultIsoDate(char[] chars, int start, DateTime dt) { int num = 19; int value; int value2; int value3; Class_502.GetDateValues(dt, out value, out value2, out value3); Class_502.CopyIntToCharArray(chars, start, value, 4); chars[start + 4] = '-'; Class_502.CopyIntToCharArray(chars, start + 5, value2, 2); chars[start + 7] = '-'; Class_502.CopyIntToCharArray(chars, start + 8, value3, 2); chars[start + 10] = 'T'; Class_502.CopyIntToCharArray(chars, start + 11, dt.Hour, 2); chars[start + 13] = ':'; Class_502.CopyIntToCharArray(chars, start + 14, dt.Minute, 2); chars[start + 16] = ':'; Class_502.CopyIntToCharArray(chars, start + 17, dt.Second, 2); int num2 = (int)(dt.Ticks % 10000000L); if (num2 != 0) { int num3 = 7; while (num2 % 10 == 0) { num3--; num2 /= 10; } chars[start + 19] = '.'; Class_502.CopyIntToCharArray(chars, start + 20, num2, num3); num += num3 + 1; } return(start + num); }
// Token: 0x060016E8 RID: 5864 RVA: 0x0006C2E9 File Offset: 0x0006A4E9 private static long ToUniversalTicks(DateTime dateTime) { if (dateTime.Kind == DateTimeKind.Utc) { return(dateTime.Ticks); } return(Class_502.ToUniversalTicks(dateTime, dateTime.GetUtcOffset())); }
// Token: 0x060016F9 RID: 5881 RVA: 0x0006CC6C File Offset: 0x0006AE6C internal static void WriteDateTimeOffsetString(TextWriter writer, DateTimeOffset value, Class_319 format, string formatString, CultureInfo culture) { if (string.IsNullOrEmpty(formatString)) { char[] array = new char[64]; int count = Class_502.WriteDateTimeString(array, 0, (format == Class_319.IsoDateFormat) ? value.DateTime : value.UtcDateTime, new TimeSpan?(value.Offset), DateTimeKind.Local, format); writer.Write(array, 0, count); return; } writer.Write(value.ToString(formatString, culture)); }
// Token: 0x060016F4 RID: 5876 RVA: 0x0006C94C File Offset: 0x0006AB4C internal static void WriteDateTimeString(TextWriter writer, DateTime value, Class_319 format, string formatString, CultureInfo culture) { if (string.IsNullOrEmpty(formatString)) { char[] array = new char[64]; int count = Class_502.WriteDateTimeString(array, 0, value, null, value.Kind, format); writer.Write(array, 0, count); return; } writer.Write(value.ToString(formatString, culture)); }
// 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: 0x060016F8 RID: 5880 RVA: 0x0006CBF8 File Offset: 0x0006ADF8 internal static int WriteDateTimeOffset(char[] chars, int start, TimeSpan offset, Class_319 format) { chars[start++] = ((offset.Ticks >= 0L) ? '+' : '-'); int value = Math.Abs(offset.Hours); Class_502.CopyIntToCharArray(chars, start, value, 2); start += 2; if (format == Class_319.IsoDateFormat) { chars[start++] = ':'; } int value2 = Math.Abs(offset.Minutes); Class_502.CopyIntToCharArray(chars, start, value2, 2); start += 2; return(start); }
// Token: 0x060016F5 RID: 5877 RVA: 0x0006C9A0 File Offset: 0x0006ABA0 internal static int WriteDateTimeString(char[] chars, int start, DateTime value, TimeSpan?offset, DateTimeKind kind, Class_319 format) { int num2; if (format == Class_319.MicrosoftDateFormat) { TimeSpan offset2 = offset ?? value.GetUtcOffset(); long num = Class_502.ConvertDateTimeToJavaScriptTicks(value, offset2); "\\/Date(".CopyTo(0, chars, start, 7); num2 = start + 7; string text = num.ToString(CultureInfo.InvariantCulture); text.CopyTo(0, chars, num2, text.Length); num2 += text.Length; switch (kind) { case DateTimeKind.Unspecified: if (value != DateTime.MaxValue && value != DateTime.MinValue) { num2 = Class_502.WriteDateTimeOffset(chars, num2, offset2, format); } break; case DateTimeKind.Local: num2 = Class_502.WriteDateTimeOffset(chars, num2, offset2, format); break; } ")\\/".CopyTo(0, chars, num2, 3); num2 += 3; } else { num2 = Class_502.WriteDefaultIsoDate(chars, start, value); switch (kind) { case DateTimeKind.Utc: chars[num2++] = 'Z'; break; case DateTimeKind.Local: num2 = Class_502.WriteDateTimeOffset(chars, num2, offset ?? value.GetUtcOffset(), format); break; } } return(num2); }
// 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: 0x060016E5 RID: 5861 RVA: 0x0006C1F8 File Offset: 0x0006A3F8 internal static DateTime EnsureDateTime(DateTime value, Class_321 timeZone) { switch (timeZone) { case Class_321.Local: value = Class_502.SwitchToLocalTime(value); break; case Class_321.Utc: value = Class_502.SwitchToUtcTime(value); break; case Class_321.Unspecified: value = new DateTime(value.Ticks, DateTimeKind.Unspecified); break; case Class_321.RoundtripKind: break; default: throw new ArgumentException("Invalid date time handling value."); } return(value); }
// 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); }
// Token: 0x060016EC RID: 5868 RVA: 0x0006C3A8 File Offset: 0x0006A5A8 internal static long ConvertDateTimeToJavaScriptTicks(DateTime dateTime, bool convertToUtc) { long universialTicks = convertToUtc ? Class_502.ToUniversalTicks(dateTime) : dateTime.Ticks; return(Class_502.UniversialTicksToJavaScriptTicks(universialTicks)); }
// Token: 0x060016EB RID: 5867 RVA: 0x0006C39F File Offset: 0x0006A59F internal static long ConvertDateTimeToJavaScriptTicks(DateTime dateTime) { return(Class_502.ConvertDateTimeToJavaScriptTicks(dateTime, true)); }
// Token: 0x060016EA RID: 5866 RVA: 0x0006C384 File Offset: 0x0006A584 internal static long ConvertDateTimeToJavaScriptTicks(DateTime dateTime, TimeSpan offset) { long universialTicks = Class_502.ToUniversalTicks(dateTime, offset); return(Class_502.UniversialTicksToJavaScriptTicks(universialTicks)); }