@@ -21,6 +21,7 @@ public static class TimeZoneInfoTests
21
21
private static String s_strLibya = s_isWindows ? "Libya Standard Time" : "Africa/Tripoli" ;
22
22
private static String s_strCatamarca = s_isWindows ? "Argentina Standard Time" : "America/Catamarca" ;
23
23
private static String s_strLisbon = Interop . IsWindows ? "GMT Standard Time" : "Europe/Lisbon" ;
24
+ private static String s_strNewfoundland = Interop . IsWindows ? "Newfoundland Standard Time" : "America/St_Johns" ;
24
25
25
26
private static TimeZoneInfo s_myUtc = TimeZoneInfo . Utc ;
26
27
private static TimeZoneInfo s_myLocal = TimeZoneInfo . Local ;
@@ -30,6 +31,7 @@ public static class TimeZoneInfoTests
30
31
private static TimeZoneInfo s_amsterdamTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strAmsterdam ) ;
31
32
private static TimeZoneInfo s_catamarcaTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strCatamarca ) ;
32
33
private static TimeZoneInfo s_LisbonTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strLisbon ) ;
34
+ private static TimeZoneInfo s_NewfoundlandTz = TimeZoneInfo . FindSystemTimeZoneById ( s_strNewfoundland ) ;
33
35
34
36
private static bool s_localIsPST = TimeZoneInfo . Local . Id == s_strPacific ;
35
37
private static bool s_regLocalSupportsDST = s_regLocal . SupportsDaylightSavingTime ;
@@ -1707,6 +1709,41 @@ public static void TestLisbonDaylightSavingsWithNoOffsetChange(string dateTimeSt
1707
1709
Assert . Equal ( offset , s_LisbonTz . GetUtcOffset ( dt ) ) ;
1708
1710
}
1709
1711
1712
+ [ Theory ]
1713
+ // Newfoundland is UTC-3:30 standard and UTC-2:30 dst
1714
+ // using non-UTC date times in this test to get some converage for non-UTC date times
1715
+ [ InlineData ( "2015-03-08T01:59:59" , false , false , false , "-3:30:00" , "-8:00:00" ) ]
1716
+ // since DST kicks in a 2AM, from 2AM - 3AM is Invalid
1717
+ [ InlineData ( "2015-03-08T02:00:00" , false , true , false , "-3:30:00" , "-8:00:00" ) ]
1718
+ [ InlineData ( "2015-03-08T02:59:59" , false , true , false , "-3:30:00" , "-8:00:00" ) ]
1719
+ [ InlineData ( "2015-03-08T03:00:00" , true , false , false , "-2:30:00" , "-8:00:00" ) ]
1720
+ [ InlineData ( "2015-03-08T07:29:59" , true , false , false , "-2:30:00" , "-8:00:00" ) ]
1721
+ [ InlineData ( "2015-03-08T07:30:00" , true , false , false , "-2:30:00" , "-7:00:00" ) ]
1722
+ [ InlineData ( "2015-11-01T00:59:59" , true , false , false , "-2:30:00" , "-7:00:00" ) ]
1723
+ [ InlineData ( "2015-11-01T01:00:00" , false , false , true , "-3:30:00" , "-7:00:00" ) ]
1724
+ [ InlineData ( "2015-11-01T01:59:59" , false , false , true , "-3:30:00" , "-7:00:00" ) ]
1725
+ [ InlineData ( "2015-11-01T02:00:00" , false , false , false , "-3:30:00" , "-7:00:00" ) ]
1726
+ [ InlineData ( "2015-11-01T05:29:59" , false , false , false , "-3:30:00" , "-7:00:00" ) ]
1727
+ [ InlineData ( "2015-11-01T05:30:00" , false , false , false , "-3:30:00" , "-8:00:00" ) ]
1728
+ public static void TestNewfoundlandTimeZone ( string dateTimeString , bool expectedDST , bool isInvalidTime , bool isAmbiguousTime ,
1729
+ string expectedOffsetString , string pacificOffsetString )
1730
+ {
1731
+ DateTime dt = DateTime . ParseExact ( dateTimeString , "s" , CultureInfo . InvariantCulture ) ;
1732
+ VerifyInv ( s_NewfoundlandTz , dt , isInvalidTime ) ;
1733
+
1734
+ if ( ! isInvalidTime )
1735
+ {
1736
+ VerifyDST ( s_NewfoundlandTz , dt , expectedDST ) ;
1737
+ VerifyAmbiguous ( s_NewfoundlandTz , dt , isAmbiguousTime ) ;
1738
+
1739
+ TimeSpan offset = TimeSpan . Parse ( expectedOffsetString , CultureInfo . InvariantCulture ) ;
1740
+ Assert . Equal ( offset , s_NewfoundlandTz . GetUtcOffset ( dt ) ) ;
1741
+
1742
+ TimeSpan pacificOffset = TimeSpan . Parse ( pacificOffsetString , CultureInfo . InvariantCulture ) ;
1743
+ VerifyConvert ( dt , s_strNewfoundland , s_strPacific , dt - ( offset - pacificOffset ) ) ;
1744
+ }
1745
+ }
1746
+
1710
1747
//
1711
1748
// Helper Methods
1712
1749
//
@@ -1817,4 +1854,10 @@ private static void VerifyInv(TimeZoneInfo tz, DateTime dt, bool expectedInvalid
1817
1854
bool ret = tz . IsInvalidTime ( dt ) ;
1818
1855
Assert . True ( expectedInvalid == ret , String . Format ( "Test with the zone {0} and date {1} failed" , tz . Id , dt ) ) ;
1819
1856
}
1857
+
1858
+ private static void VerifyAmbiguous ( TimeZoneInfo tz , DateTime dt , bool expectedAmbiguous )
1859
+ {
1860
+ bool ret = tz . IsAmbiguousTime ( dt ) ;
1861
+ Assert . True ( expectedAmbiguous == ret , String . Format ( "Test with the zone {0} and date {1} failed" , tz . Id , dt ) ) ;
1862
+ }
1820
1863
}
0 commit comments