-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:
@@ -26,10 +26,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
|
||||
namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
@@ -53,5 +55,14 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
return @"@""" + json.Replace(@"""", @"""""") + @"""";
|
||||
}
|
||||
|
||||
protected string GetOffset(DateTime d, DateFormatHandling dateFormatHandling)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
JsonConvert.WriteDateTimeOffset(sw, DateTime.SpecifyKind(d, DateTimeKind.Local).GetUtcOffset(), dateFormatHandling);
|
||||
sw.Flush();
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user