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
@@ -72,7 +75,7 @@ public static void ValidateLibyaTimeZoneTest()
72
75
// Make sure first the timezone data is updated in the machine as it should include Libya Timezone
73
76
try
74
77
{
75
- tripoli = TimeZoneInfo . FindSystemTimeZoneById ( "Libya Standard Time" ) ;
78
+ tripoli = TimeZoneInfo . FindSystemTimeZoneById ( s_strLibya ) ;
76
79
}
77
80
catch ( Exception /* TimeZoneNotFoundException */ )
78
81
{
@@ -90,10 +93,10 @@ public static void ValidateLibyaTimeZoneTest()
90
93
}
91
94
92
95
[ Fact ]
93
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
96
+ [ ActiveIssue ( 2465 , PlatformID . AnyUnix ) ]
94
97
public static void ValidateRussiaTimeZoneTest ( )
95
98
{
96
- TimeZoneInfo tz = TimeZoneInfo . FindSystemTimeZoneById ( "Russian Standard Time" ) ;
99
+ TimeZoneInfo tz = TimeZoneInfo . FindSystemTimeZoneById ( s_strRussian ) ;
97
100
var inputUtcDate = new DateTime ( 2013 , 6 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
98
101
99
102
DateTime russiaTime = TimeZoneInfo . ConvertTime ( inputUtcDate , tz ) ;
@@ -106,7 +109,6 @@ public static void ValidateRussiaTimeZoneTest()
106
109
}
107
110
108
111
[ Fact ]
109
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
110
112
public static void ValidateExceptionsTest ( )
111
113
{
112
114
DateTimeOffset time1 = new DateTimeOffset ( 2006 , 5 , 12 , 0 , 0 , 0 , TimeSpan . Zero ) ;
@@ -134,7 +136,6 @@ public static void ValidateExceptionsTest()
134
136
}
135
137
136
138
[ Fact ]
137
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
138
139
public static void NearMinMaxDateTimeOffsetConvertTest ( )
139
140
{
140
141
VerifyConvert ( DateTimeOffset . MaxValue , TimeZoneInfo . Utc . Id , DateTimeOffset . MaxValue ) ;
@@ -156,15 +157,20 @@ public static void NearMinMaxDateTimeOffsetConvertTest()
156
157
VerifyConvert ( new DateTimeOffset ( DateTime . MinValue . AddHours ( 5 ) , new TimeSpan ( - 3 , 0 , 0 ) ) , s_strPacific , new DateTimeOffset ( DateTime . MinValue , new TimeSpan ( - 8 , 0 , 0 ) ) ) ;
157
158
158
159
VerifyConvert ( DateTime . MaxValue , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
159
- VerifyConvert ( DateTime . MaxValue . AddHours ( - 19 ) , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
160
+ if ( Interop . IsWindows ) // [ActiveIssue(2465, PlatformID.AnyUnix)]
161
+ {
162
+ VerifyConvert ( DateTime . MaxValue . AddHours ( - 19 ) , s_strPacific , s_strSydney , DateTime . MaxValue ) ;
163
+ }
160
164
VerifyConvert ( DateTime . MaxValue . AddHours ( - 19.5 ) , s_strPacific , s_strSydney , DateTime . MaxValue . AddHours ( - 0.5 ) ) ;
161
165
VerifyConvert ( DateTime . MinValue , s_strSydney , s_strPacific , DateTime . MinValue ) ;
162
- VerifyConvert ( DateTime . MinValue . AddHours ( 19 ) , s_strSydney , s_strPacific , DateTime . MinValue ) ;
163
- VerifyConvert ( DateTime . MinValue . AddHours ( 19.5 ) , s_strSydney , s_strPacific , DateTime . MinValue . AddHours ( 0.5 ) ) ;
166
+ if ( Interop . IsWindows ) // [ActiveIssue(2465, PlatformID.AnyUnix)]
167
+ {
168
+ VerifyConvert ( DateTime . MinValue . AddHours ( 19 ) , s_strSydney , s_strPacific , DateTime . MinValue ) ;
169
+ VerifyConvert ( DateTime . MinValue . AddHours ( 19.5 ) , s_strSydney , s_strPacific , DateTime . MinValue . AddHours ( 0.5 ) ) ;
170
+ }
164
171
}
165
172
166
173
[ Fact ]
167
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
168
174
public static void DateTimeOffsetVariousSystemTimeZonesTest ( )
169
175
{
170
176
var time1 = new DateTimeOffset ( 2006 , 5 , 12 , 5 , 17 , 42 , new TimeSpan ( - 7 , 0 , 0 ) ) ;
@@ -273,7 +279,6 @@ public static void DateTimeOffsetVariousSystemTimeZonesTest()
273
279
}
274
280
275
281
[ Fact ]
276
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
277
282
public static void SameTimeZonesTest ( )
278
283
{
279
284
var time1 = new DateTimeOffset ( 2003 , 10 , 26 , 3 , 0 , 1 , new TimeSpan ( - 2 , 0 , 0 ) ) ;
@@ -451,7 +456,6 @@ public static void PerthRulesTest()
451
456
}
452
457
453
458
[ Fact ]
454
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
455
459
public static void UtcToUtcTest ( )
456
460
{
457
461
var time1utc = new DateTime ( 2003 , 3 , 30 , 0 , 0 , 23 , DateTimeKind . Utc ) ;
@@ -469,7 +473,6 @@ public static void UtcToUtcTest()
469
473
}
470
474
471
475
[ Fact ]
472
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
473
476
public static void UtcToLocalTest ( )
474
477
{
475
478
if ( s_localIsPST )
@@ -736,7 +739,6 @@ public static void LocalToUtcTest()
736
739
}
737
740
738
741
[ Fact ]
739
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
740
742
public static void DtKindTest ( )
741
743
{
742
744
VerifyConvertException < ArgumentException > ( new DateTime ( 2006 , 2 , 13 , 5 , 37 , 48 , DateTimeKind . Utc ) , s_strPacific , s_strSydney ) ;
@@ -753,7 +755,6 @@ public static void DtKindTest()
753
755
}
754
756
755
757
[ Fact ]
756
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
757
758
public static void MiscUtcTests ( )
758
759
{
759
760
VerifyConvert ( new DateTime ( 2003 , 4 , 6 , 1 , 30 , 0 , DateTimeKind . Utc ) , "UTC" , DateTime . SpecifyKind ( new DateTime ( 2003 , 4 , 6 , 1 , 30 , 0 ) , DateTimeKind . Utc ) ) ;
@@ -809,7 +810,6 @@ public static void MiscUtcTests()
809
810
}
810
811
811
812
[ Fact ]
812
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
813
813
public static void BrasiliaTests ( )
814
814
{
815
815
var time1 = new DateTimeOffset ( 2003 , 10 , 26 , 3 , 0 , 1 , new TimeSpan ( - 2 , 0 , 0 ) ) ;
@@ -829,7 +829,6 @@ public static void BrasiliaTests()
829
829
}
830
830
831
831
[ Fact ]
832
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
833
832
public static void TongaTests ( )
834
833
{
835
834
var time1 = new DateTime ( 2006 , 5 , 12 , 5 , 17 , 42 , DateTimeKind . Utc ) ;
@@ -918,7 +917,6 @@ public static void ThrowOnAmbiguousOffsetsTests()
918
917
}
919
918
920
919
[ Fact ]
921
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
922
920
public static void ThrowOnNairobiAmbiguousOffsetsTests ( )
923
921
{
924
922
VerifyAmbiguousOffsetsException < ArgumentException > ( s_nairobiTz , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) ) ;
@@ -934,7 +932,6 @@ public static void ThrowOnNairobiAmbiguousOffsetsTests()
934
932
}
935
933
936
934
[ Fact ]
937
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
938
935
public static void AmsterdamAmbiguousOffsetsTests ( )
939
936
{
940
937
//
@@ -1178,7 +1175,6 @@ public static void AmsterdamAmbiguousOffsetsTests()
1178
1175
}
1179
1176
1180
1177
[ Fact ]
1181
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1182
1178
public static void LocalAmbiguousOffsetsTests ( )
1183
1179
{
1184
1180
if ( ! s_localIsPST )
@@ -1218,7 +1214,6 @@ public static void LocalAmbiguousOffsetsTests()
1218
1214
}
1219
1215
1220
1216
[ Fact ]
1221
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1222
1217
public static void DstTests ( )
1223
1218
{
1224
1219
VerifyDST ( TimeZoneInfo . Utc , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) , false ) ;
@@ -1421,7 +1416,6 @@ public static void DstTests()
1421
1416
}
1422
1417
1423
1418
[ Fact ]
1424
- [ ActiveIssue ( 846 , PlatformID . AnyUnix ) ]
1425
1419
public static void InvalidTimeTests ( )
1426
1420
{
1427
1421
VerifyInv ( TimeZoneInfo . Utc , new DateTime ( 2006 , 1 , 15 , 7 , 15 , 23 ) , false ) ;
0 commit comments