@@ -119,6 +119,40 @@ public static void LibyaTimeZone()
119119 Assert . True ( libyaLocalTime . Equals ( expectResult ) , string . Format ( "Expected {0} and got {1}" , expectResult , libyaLocalTime ) ) ;
120120 }
121121
122+ [ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsWindows ) ) ]
123+ public static void TestYukunTZ ( )
124+ {
125+ try
126+ {
127+ TimeZoneInfo yukon = TimeZoneInfo . FindSystemTimeZoneById ( "Yukon Standard Time" ) ;
128+
129+ // First, ensure we have the updated data
130+ TimeZoneInfo . AdjustmentRule [ ] rules = yukon . GetAdjustmentRules ( ) ;
131+ if ( rules . Length <= 0 || rules [ rules . Length - 1 ] . DateStart . Year != 2021 || rules [ rules . Length - 1 ] . DateEnd . Year != 9999 )
132+ {
133+ return ;
134+ }
135+
136+ TimeSpan minus7HoursSpan = new TimeSpan ( - 7 , 0 , 0 ) ;
137+
138+ DateTimeOffset midnight = new DateTimeOffset ( 2021 , 1 , 1 , 0 , 0 , 0 , 0 , minus7HoursSpan ) ;
139+ DateTimeOffset beforeMidnight = new DateTimeOffset ( 2020 , 12 , 31 , 23 , 59 , 59 , 999 , minus7HoursSpan ) ;
140+ DateTimeOffset before1AM = new DateTimeOffset ( 2021 , 1 , 1 , 0 , 59 , 59 , 999 , minus7HoursSpan ) ;
141+ DateTimeOffset at1AM = new DateTimeOffset ( 2021 , 1 , 1 , 1 , 0 , 0 , 0 , minus7HoursSpan ) ;
142+ DateTimeOffset midnight2022 = new DateTimeOffset ( 2022 , 1 , 1 , 0 , 0 , 0 , 0 , minus7HoursSpan ) ;
143+
144+ Assert . Equal ( minus7HoursSpan , yukon . GetUtcOffset ( midnight ) ) ;
145+ Assert . Equal ( minus7HoursSpan , yukon . GetUtcOffset ( beforeMidnight ) ) ;
146+ Assert . Equal ( minus7HoursSpan , yukon . GetUtcOffset ( before1AM ) ) ;
147+ Assert . Equal ( minus7HoursSpan , yukon . GetUtcOffset ( at1AM ) ) ;
148+ Assert . Equal ( minus7HoursSpan , yukon . GetUtcOffset ( midnight2022 ) ) ;
149+ }
150+ catch ( TimeZoneNotFoundException )
151+ {
152+ // Some Windows versions don't carry the complete TZ data. Ignore the tests on such versiosn.
153+ }
154+ }
155+
122156 [ Fact ]
123157 public static void RussianTimeZone ( )
124158 {
0 commit comments