Code Coverage Statistics for Source File
Newtonsoft.Json\Utilities\DateTimeUtils.cs
Symbol Coverage: 66.67% (6 of 9)
Branch Coverage: 75.00% (3 of 4)
Cyclomatic Complexity Avg: 2.00 Max:3
Code Lines: 9
Symbol Coverage Trend
View:
L | V | Source |
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Xml; |
|
6 |
using System.Globalization; |
|
7 |
||
8 |
namespace Newtonsoft.Json.Utilities |
|
9 |
{ |
|
10 |
internal static class DateTimeUtils |
|
11 |
{ |
|
12 |
public static string GetLocalOffset(this DateTime d) |
|
13 |
{ |
|
14 |
TimeSpan utcOffset; |
|
15 |
#if PocketPC || NET20 |
|
16 |
utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(d); |
|
17 |
#else |
|
18 |
1 |
utcOffset = TimeZoneInfo.Local.GetUtcOffset(d);
|
19 |
#endif |
|
20 |
||
21 |
1 |
return utcOffset.Hours.ToString("+00;-00", CultureInfo.InvariantCulture) + ":" + utcOffset.Minutes.ToString("00;00", CultureInfo.InvariantCulture);
|
22 |
1 |
}
|
23 |
||
24 |
public static XmlDateTimeSerializationMode ToSerializationMode(DateTimeKind kind) |
|
25 |
{ |
|
26 |
2 |
switch (kind)
|
27 |
{ |
|
28 |
case DateTimeKind.Local: |
|
29 |
0 |
return XmlDateTimeSerializationMode.Local;
|
30 |
case DateTimeKind.Unspecified: |
|
31 |
0 |
return XmlDateTimeSerializationMode.Unspecified;
|
32 |
case DateTimeKind.Utc: |
|
33 |
2 |
return XmlDateTimeSerializationMode.Utc;
|
34 |
default: |
|
35 |
0 |
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("kind", kind, "Unexpected DateTimeKind value.");
|
36 |
} |
|
37 |
2 |
}
|
38 |
} |
|
39 |
} |