/// <summary> /// 时间转换 /// </summary> /// <param name="value">时间</param> internal void SerializeDateTime(DateTime value) { if (value == DateTime.MinValue && Config.IsDateTimeMinNull) { CharStream.WriteJsonNull(); return; } switch (Config.DateTimeType) { case DateTimeType.Default: CharStream.WriteJsonString(value); return; case DateTimeType.Sql: CharStream.WriteJsonSqlString(value); return; case DateTimeType.Javascript: CharStream.WriteJsonNewDate(); CallSerialize(((value.Kind == DateTimeKind.Utc ? value.Ticks + Date.LocalTimeTicks : value.Ticks) - AutoCSer.JsonDeSerializer.JavascriptLocalMinTimeTicks) / TimeSpan.TicksPerMillisecond); CharStream.Data.Write(')'); return; case DateTimeType.ThirdParty: CharStream.WriteJsonOtherDate(); CallSerialize(((value.Kind == DateTimeKind.Utc ? value.Ticks + Date.LocalTimeTicks : value.Ticks) - AutoCSer.JsonDeSerializer.JavascriptLocalMinTimeTicks) / TimeSpan.TicksPerMillisecond); CharStream.WriteJsonOtherDateEnd(); return; case DateTimeType.CustomFormat: if (Config.DateTimeCustomFormat == null) { primitiveSerialize(value.ToString()); } else { primitiveSerialize(value.ToString(Config.DateTimeCustomFormat)); } return; } }