@@ -5663,12 +5663,34 @@ def test_astimezone_default_near_fold(self):
56635663
56645664 @unittest .skipIf (sys .platform != "win32" , "gh-148658 only affects Windows" )
56655665 def test_astimezone_negative_timestamp_dst (self ):
5666- # gh-148658: astimezone() returned DST name for negative timestamps
5667- # on Windows. Verify that the timezone name is consistent between
5668- # negative and non-negative timestamps.
5669- dt_neg1 = self .theclass .fromtimestamp (- 1 ).astimezone ()
5670- dt_zero = self .theclass .fromtimestamp (0 ).astimezone ()
5671- self .assertEqual (dt_neg1 .tzname (), dt_zero .tzname ())
5666+ # gh-148658: astimezone() returned incorrect DST name for negative
5667+ # timestamps on Windows. Verify C layer returns correct tm_zone
5668+ # by checking astimezone() produces correct timezone names.
5669+ import time
5670+ winter_ts = - 1 # 1969-12-31
5671+ summer_ts = - 15897600 # 1969-07-01
5672+
5673+ # Get expected timezone names from time.localtime
5674+ winter_local = time .localtime (winter_ts )
5675+ summer_local = time .localtime (summer_ts )
5676+
5677+ dt_winter = self .theclass .fromtimestamp (winter_ts ).astimezone ()
5678+ dt_summer = self .theclass .fromtimestamp (summer_ts ).astimezone ()
5679+
5680+ # Verify astimezone() returns correct timezone names
5681+ self .assertEqual (dt_winter .tzname (), winter_local .tm_zone )
5682+ self .assertEqual (dt_summer .tzname (), summer_local .tm_zone )
5683+
5684+ # For DST timezones, winter and summer should have different names
5685+ # For non-DST timezones, names should be the same
5686+ if winter_local .tm_zone == summer_local .tm_zone :
5687+ # Non-DST timezone: both should be standard time
5688+ self .assertEqual (winter_local .tm_isdst , 0 )
5689+ self .assertEqual (summer_local .tm_isdst , 0 )
5690+ else :
5691+ # DST timezone: one should be standard, one DST
5692+ self .assertEqual (winter_local .tm_isdst , 0 )
5693+ self .assertEqual (summer_local .tm_isdst , 1 )
56725694
56735695 def test_aware_subtract (self ):
56745696 cls = self .theclass
0 commit comments