@@ -3214,6 +3214,31 @@ def test_strftime_special(self):
32143214 self .assertEqual (t .strftime ('\0 %c\0 %B' ), f'\0 { s1 } \0 { s2 } ' )
32153215 self .assertEqual (t .strftime ('%c\0 %B\0 ' ), f'{ s1 } \0 { s2 } \0 ' )
32163216
3217+ @support .run_with_tz ('EST+05EDT,M3.2.0,M11.1.0' )
3218+ def test_strftime_naive_s (self ):
3219+ t = self .theclass (1970 , 1 , 1 )
3220+ self .assertEqual (t .strftime ('%s' ), '18000' )
3221+ t = self .theclass (1970 , 1 , 1 , 1 , 2 , 3 , 4 )
3222+ self .assertEqual (t .strftime ('%s' ),
3223+ str (18000 + 3600 + 2 * 60 + 3 ))
3224+
3225+ def test_strftime_respect_timezone_s (self ):
3226+ t = self .theclass (1970 , 1 , 1 , 0 , 0 , 0 , 0 , tzinfo = timezone .utc )
3227+ self .assertEqual (t .strftime ('%s' ), '0' )
3228+
3229+ t = self .theclass (1970 , 1 , 1 , 1 , 2 , 3 , 600000 , tzinfo = timezone .utc )
3230+ self .assertEqual (t .strftime ('%s' ),
3231+ str (3600 + 2 * 60 + 3 ))
3232+
3233+ t = self .theclass (1970 , 1 , 1 , 1 , 2 , 3 , 400000 ,
3234+ tzinfo = timezone (timedelta (hours = - 5 ), 'EST' ))
3235+ self .assertEqual (t .strftime ('%s' ),
3236+ str (18000 + 3600 + 2 * 60 + 3 ))
3237+
3238+ t = self .theclass (1969 , 1 , 1 , 0 , 0 , 0 , 700000 ,
3239+ tzinfo = timezone .utc )
3240+ self .assertEqual (t .strftime ('%s' ), '-31536000' )
3241+
32173242 def test_extract (self ):
32183243 dt = self .theclass (2002 , 3 , 4 , 18 , 45 , 3 , 1234 )
32193244 self .assertEqual (dt .date (), date (2002 , 3 , 4 ))
0 commit comments