-Added DateFormatHandling to control whether dates are written in the MS format or ISO format, with ISO as the default
-Added DateTimeZoneHandling to control reading and writing DateTime time zone details -Added reader/writer specific Formatting, DateFormatHandling and DateTimeZoneHandling to JsonSerializerSettings -Added feature of reader/writer specific settings to be set on JsonReader/JsonWriter when serializing -Added ReadAsDate to JsonReader -Added ReadAsString to JsonReader -Changed JsonTextReader to automatically read ISO strings as dates -Refactored ReadAsXXX methods and reduce code redundancy -Removed unused JsonDateTimeSerializationMode
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@@ -426,8 +427,10 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
||||
public override void WriteValue(DateTime value)
|
||||
{
|
||||
|
||||
|
||||
base.WriteValue(value);
|
||||
JsonConvert.WriteDateTimeString(_writer, value);
|
||||
JsonConvert.WriteDateTimeString(_writer, value, DateFormatHandling);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -455,7 +458,7 @@ namespace Newtonsoft.Json
|
||||
public override void WriteValue(DateTimeOffset value)
|
||||
{
|
||||
base.WriteValue(value);
|
||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Date);
|
||||
WriteValueInternal(JsonConvert.ToString(value, DateFormatHandling), JsonToken.Date);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user