-Changed time zone conversions to use new TimeZoneInfo instead of TimeZone

This commit is contained in:
JamesNK
2011-11-01 10:45:46 +00:00
parent b305ba100b
commit c7de25a37a
4 changed files with 16 additions and 34 deletions
@@ -73,7 +73,7 @@ namespace Newtonsoft.Json.Tests.Converters
d = new DateTime(2000, 12, 15, 22, 11, 3, 55, DateTimeKind.Local);
result = JsonConvert.SerializeObject(d, converter);
Assert.AreEqual(@"""2000-12-15T22:11:03.055" + d.GetLocalOffset() + @"""", result);
Assert.AreEqual(@"""2000-12-15T22:11:03.055" + d.GetUtcOffsetText() + @"""", result);
}
[Test]
@@ -272,13 +272,7 @@ namespace Newtonsoft.Json.Tests.Converters
c.DateTimeField = new DateTime(2008, 1, 1, 1, 1, 1, 0, DateTimeKind.Utc);
string json2 = JsonConvert.SerializeObject(c, new IsoDateTimeConverter() { DateTimeStyles = DateTimeStyles.AssumeUniversal });
TimeSpan offset;
#if SILVERLIGHT
offset = TimeZoneInfo.Local.GetUtcOffset(localDateTime);
#else
offset = TimeZone.CurrentTimeZone.GetUtcOffset(localDateTime);
#endif
TimeSpan offset = localDateTime.GetUtcOffset();
// if the current timezone is utc then local already equals utc
if (offset == TimeSpan.Zero)
@@ -44,13 +44,6 @@ namespace Newtonsoft.Json.Tests
//Thread.CurrentThread.CurrentUICulture = turkey;
}
//public string GetOffset(DateTime value)
//{
// TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(value.ToLocalTime());
// return utcOffset.Hours.ToString("+00;-00") + utcOffset.Minutes.ToString("00;00");
//}
protected void WriteEscapedJson(string json)
{
Console.WriteLine(EscapeJson(json));