2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System ;
5
+ using System . Runtime . InteropServices ;
5
6
using Xunit ;
6
7
7
8
public static class TimeZoneInfoTests
8
9
{
9
- private static String s_strPacific = "Pacific Standard Time" ;
10
- private static String s_strSydney = "AUS Eastern Standard Time" ;
11
- private static String s_strGMT = "GMT Standard Time" ;
12
- private static String s_strTonga = "Tonga Standard Time" ;
13
- private static String s_strBrasil = "E. South America Standard Time" ;
14
- private static String s_strPerth = "W. Australia Standard Time" ;
15
- private static String s_strBrasilia = "E. South America Standard Time" ;
16
- private static String s_strNairobi = "E. Africa Standard Time" ;
17
- private static String s_strAmsterdam = "W. Europe Standard Time" ;
10
+ private static String s_strPacific = Interop . IsWindows ? "Pacific Standard Time" : "America/Los_Angeles" ;
11
+ private static String s_strSydney = Interop . IsWindows ? "AUS Eastern Standard Time" : "Australia/Sydney" ;
12
+ private static String s_strGMT = Interop . IsWindows ? "GMT Standard Time" : "Europe/London" ;
13
+ private static String s_strTonga = Interop . IsWindows ? "Tonga Standard Time" : "Pacific/Tongatapu" ;
14
+ private static String s_strBrasil = Interop . IsWindows ? "E. South America Standard Time" : "America/Sao_Paulo" ;
15
+ private static String s_strPerth = Interop . IsWindows ? "W. Australia Standard Time" : "Australia/Perth" ;
16
+ private static String s_strBrasilia = Interop . IsWindows ? "E. South America Standard Time" : "America/Sao_Paulo" ;
17
+ private static String s_strNairobi = Interop . IsWindows ? "E. Africa Standard Time" : "Africa/Nairobi" ;
18
+ private static String s_strAmsterdam = Interop . IsWindows ? "W. Europe Standard Time" : "Europe/Berlin" ;
19
+ private static String s_strRussian = Interop . IsWindows ? "Russian Standard Time" : "Europe/Moscow" ;
20
+ private static String s_strLibya = Interop . IsWindows ? "Libya Standard Time" : "Africa/Tripoli" ;
18
21
19
22
private static TimeZoneInfo s_myUtc = TimeZoneInfo . Utc ;
20
23
private static TimeZoneInfo s_myLocal = TimeZoneInfo . Local ;
@@ -23,7 +26,7 @@ public static class TimeZoneInfoTests
23
26
private static TimeZoneInfo s_nairobiTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strNairobi ) ;
24
27
private static TimeZoneInfo s_amsterdamTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strAmsterdam ) ;
25
28
26
- private static bool s_localIsPST = TimeZoneInfo . Local . StandardName == "Pacific Standard Time" ;
29
+ private static bool s_localIsPST = TimeZoneInfo . Local . Id == s_strPacific ;
27
30
private static bool s_regLocalSupportsDST = s_regLocal . SupportsDaylightSavingTime ;
28
31
private static bool s_localSupportsDST = TimeZoneInfo . Local . SupportsDaylightSavingTime ;
29
32
@@ -75,7 +78,7 @@ public static void ValidateLibyaTimeZoneTest()
75
78
// Make sure first the timezone data is updated in the machine as it should include Libya Timezone
76
79
try
77
80
{
78
- tripoli = TimeZoneInfo . FindSystemTimeZoneById ( "Libya Standard Time" ) ;
81
+ tripoli = TimeZoneInfo . FindSystemTimeZoneById ( s_strLibya ) ;
79
82
}
80
83
catch ( Exception /* TimeZoneNotFoundException */ )
81
84
{
@@ -96,7 +99,7 @@ public static void ValidateLibyaTimeZoneTest()
96
99
[ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
97
100
public static void ValidateRussiaTimeZoneTest ( )
98
101
{
99
- TimeZoneInfo tz = TimeZoneInfo . FindSystemTimeZoneById ( "Russian Standard Time" ) ;
102
+ TimeZoneInfo tz = TimeZoneInfo . FindSystemTimeZoneById ( s_strRussian ) ;
100
103
var inputUtcDate = new DateTime ( 2013 , 6 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
101
104
102
105
DateTime russiaTime = TimeZoneInfo . ConvertTime ( inputUtcDate , tz ) ;
@@ -109,7 +112,6 @@ public static void ValidateRussiaTimeZoneTest()
109
112
}
110
113
111
114
[ Fact ]
112
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
113
115
public static void ValidateExceptionsTest ( )
114
116
{
115
117
DateTimeOffset time1 = new DateTimeOffset ( 2006 , 5 , 12 , 0 , 0 , 0 , TimeSpan . Zero ) ;
@@ -137,7 +139,6 @@ public static void ValidateExceptionsTest()
137
139
}
138
140
139
141
[ Fact ]
140
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
141
142
public static void NearMinMaxDateTimeOffsetConvertTest ( )
142
143
{
143
144
VerifyConvert ( DateTimeOffset . MaxValue , TimeZoneInfo . Utc . Id , DateTimeOffset . MaxValue ) ;
@@ -159,15 +160,20 @@ public static void NearMinMaxDateTimeOffsetConvertTest()
159
160
VerifyConvert ( new DateTimeOffset ( DateTime . MinValue . AddHours ( 5 ) , new TimeSpan ( - 3 , 0 , 0 ) ) , s_strPacific , new DateTimeOffset ( DateTime . MinValue , new TimeSpan ( - 8 , 0 , 0 ) ) ) ;
160
161
161
162
VerifyConvert ( DateTime . MaxValue , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
162
- VerifyConvert ( DateTime . MaxValue . AddHours ( - 19 ) , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
163
+ if ( Interop . IsWindows ) // [ActiveIssue(846, PlatformID.AnyUnix)]
164
+ {
165
+ VerifyConvert ( DateTime . MaxValue . AddHours ( - 19 ) , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
166
+ }
163
167
VerifyConvert ( DateTime . MaxValue . AddHours ( - 19.5 ) , s_strPacific , s_strSydney , DateTime . MaxValue . AddHours ( - 0.5 ) ) ;
164
168
VerifyConvert ( DateTime . MinValue , s_strSydney , s_strPacific , DateTime . MinValue ) ;
165
- VerifyConvert ( DateTime . MinValue . AddHours ( 19 ) , s_strSydney , s_strPacific , DateTime . MinValue ) ;
166
- VerifyConvert ( DateTime . MinValue . AddHours ( 19.5 ) , s_strSydney , s_strPacific , DateTime . MinValue . AddHours ( 0.5 ) ) ;
169
+ if ( Interop . IsWindows ) // [ActiveIssue(846, PlatformID.AnyUnix)]
170
+ {
171
+ VerifyConvert ( DateTime . MinValue . AddHours ( 19 ) , s_strSydney , s_strPacific , DateTime . MinValue ) ;
172
+ VerifyConvert ( DateTime . MinValue . AddHours ( 19.5 ) , s_strSydney , s_strPacific , DateTime . MinValue . AddHours ( 0.5 ) ) ;
173
+ }
167
174
}
168
175
169
176
[ Fact ]
170
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
171
177
public static void DateTimeOffsetVariousSystemTimeZonesTest ( )
172
178
{
173
179
var time1 = new DateTimeOffset ( 2006 , 5 , 12 , 5 , 17 , 42 , new TimeSpan ( - 7 , 0 , 0 ) ) ;
@@ -276,7 +282,6 @@ public static void DateTimeOffsetVariousSystemTimeZonesTest()
276
282
}
277
283
278
284
[ Fact ]
279
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
280
285
public static void SameTimeZonesTest ( )
281
286
{
282
287
var time1 = new DateTimeOffset ( 2003 , 10 , 26 , 3 , 0 , 1 , new TimeSpan ( - 2 , 0 , 0 ) ) ;
@@ -454,7 +459,6 @@ public static void PerthRulesTest()
454
459
}
455
460
456
461
[ Fact ]
457
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
458
462
public static void UtcToUtcTest ( )
459
463
{
460
464
var time1utc = new DateTime ( 2003 , 3 , 30 , 0 , 0 , 23 , DateTimeKind . Utc ) ;
@@ -472,7 +476,6 @@ public static void UtcToUtcTest()
472
476
}
473
477
474
478
[ Fact ]
475
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
476
479
public static void UtcToLocalTest ( )
477
480
{
478
481
if ( s_localIsPST )
@@ -739,7 +742,6 @@ public static void LocalToUtcTest()
739
742
}
740
743
741
744
[ Fact ]
742
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
743
745
public static void DtKindTest ( )
744
746
{
745
747
VerifyConvertException < ArgumentException > ( new DateTime ( 2006 , 2 , 13 , 5 , 37 , 48 , DateTimeKind . Utc ) , s_strPacific , s_strSydney ) ;
@@ -756,7 +758,6 @@ public static void DtKindTest()
756
758
}
757
759
758
760
[ Fact ]
759
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
760
761
public static void MiscUtcTests ( )
761
762
{
762
763
VerifyConvert ( new DateTime ( 2003 , 4 , 6 , 1 , 30 , 0 , DateTimeKind . Utc ) , "UTC" , DateTime . SpecifyKind ( new DateTime ( 2003 , 4 , 6 , 1 , 30 , 0 ) , DateTimeKind . Utc ) ) ;
@@ -812,7 +813,6 @@ public static void MiscUtcTests()
812
813
}
813
814
814
815
[ Fact ]
815
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
816
816
public static void BrasiliaTests ( )
817
817
{
818
818
var time1 = new DateTimeOffset ( 2003 , 10 , 26 , 3 , 0 , 1 , new TimeSpan ( - 2 , 0 , 0 ) ) ;
@@ -832,7 +832,6 @@ public static void BrasiliaTests()
832
832
}
833
833
834
834
[ Fact ]
835
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
836
835
public static void TongaTests ( )
837
836
{
838
837
var time1 = new DateTime ( 2006 , 5 , 12 , 5 , 17 , 42 , DateTimeKind . Utc ) ;
@@ -921,7 +920,6 @@ public static void ThrowOnAmbiguousOffsetsTests()
921
920
}
922
921
923
922
[ Fact ]
924
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
925
923
public static void ThrowOnNairobiAmbiguousOffsetsTests ( )
926
924
{
927
925
VerifyAmbiguousOffsetsException < ArgumentException > ( s_nairobiTz , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) ) ;
@@ -937,7 +935,6 @@ public static void ThrowOnNairobiAmbiguousOffsetsTests()
937
935
}
938
936
939
937
[ Fact ]
940
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
941
938
public static void AmsterdamAmbiguousOffsetsTests ( )
942
939
{
943
940
//
@@ -1181,7 +1178,6 @@ public static void AmsterdamAmbiguousOffsetsTests()
1181
1178
}
1182
1179
1183
1180
[ Fact ]
1184
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1185
1181
public static void LocalAmbiguousOffsetsTests ( )
1186
1182
{
1187
1183
if ( ! s_localIsPST )
@@ -1221,7 +1217,6 @@ public static void LocalAmbiguousOffsetsTests()
1221
1217
}
1222
1218
1223
1219
[ Fact ]
1224
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1225
1220
public static void DstTests ( )
1226
1221
{
1227
1222
VerifyDST ( TimeZoneInfo . Utc , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) , false ) ;
@@ -1424,7 +1419,6 @@ public static void DstTests()
1424
1419
}
1425
1420
1426
1421
[ Fact ]
1427
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1428
1422
public static void InvalidTimeTests ( )
1429
1423
{
1430
1424
VerifyInv ( TimeZoneInfo . Utc , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) , false ) ;
0 commit comments