1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| internal static int WriteDateTimeString(char[] chars, int start, DateTime value, TimeSpan? offset, DateTimeKind kind, DateFormatHandling format) { int pos = start;
if (format == DateFormatHandling.MicrosoftDateFormat) { TimeSpan o = offset ?? value.GetUtcOffset();
long javaScriptTicks = ConvertDateTimeToJavaScriptTicks(value, o);
@"\/Date(".CopyTo(0, chars, pos, 7); pos += 7;
string ticksText = javaScriptTicks.ToString(CultureInfo.InvariantCulture); ticksText.CopyTo(0, chars, pos, ticksText.Length); pos += ticksText.Length;
switch (kind) { case DateTimeKind.Unspecified: if (value != DateTime.MaxValue && value != DateTime.MinValue) { pos = WriteDateTimeOffset(chars, pos, o, format); } break; case DateTimeKind.Local: pos = WriteDateTimeOffset(chars, pos, o, format); break; }
@")\/".CopyTo(0, chars, pos, 3); pos += 3; } else { pos = WriteDefaultIsoDate(chars, pos, value);
switch (kind) { case DateTimeKind.Local: pos = WriteDateTimeOffset(chars, pos, offset ?? value.GetUtcOffset(), format); break; case DateTimeKind.Utc: chars[pos++] = 'Z'; break; } }
return pos; }
|