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):
156
156
value = utc .localize (value )
157
157
seconds , nanoseconds = seconds_and_nanoseconds (value )
158
158
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
161
161
seconds , nanoseconds = seconds_and_nanoseconds (value )
162
162
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 )
163
167
else :
164
168
# with time offset
165
169
seconds , nanoseconds = seconds_and_nanoseconds (value )
You can’t perform that action at this time.
0 commit comments