File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -156,10 +156,14 @@ def seconds_and_nanoseconds(dt):
156156 value = utc .localize (value )
157157 seconds , nanoseconds = seconds_and_nanoseconds (value )
158158 return Structure (b"d" , seconds , nanoseconds )
159- elif hasattr (tz , "zone" ) and tz .zone :
160- # with named time zone
159+ elif hasattr (tz , "zone" ) and tz .zone and isinstance ( tz . zone , str ) :
160+ # with named pytz time zone
161161 seconds , nanoseconds = seconds_and_nanoseconds (value )
162162 return Structure (b"f" , seconds , nanoseconds , tz .zone )
163+ elif hasattr (tz , "key" ) and tz .key and isinstance (tz .key , str ):
164+ # with named zoneinfo (Python 3.9+) time zone
165+ seconds , nanoseconds = seconds_and_nanoseconds (value )
166+ return Structure (b"f" , seconds , nanoseconds , tz .key )
163167 else :
164168 # with time offset
165169 seconds , nanoseconds = seconds_and_nanoseconds (value )
You can’t perform that action at this time.
0 commit comments