File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 1515use std:: sync:: Arc ;
1616
1717use chrono:: offset:: Offset ;
18- use chrono:: { DateTime , Duration , NaiveDate } ;
19- #[ cfg( not( Py_3_9 ) ) ]
18+ #[ cfg( feature = "cp38" ) ]
2019use chrono:: FixedOffset ;
20+ use chrono:: { DateTime , Duration , NaiveDate } ;
2121use chrono_tz:: Tz ;
2222use once_cell:: sync:: Lazy ;
2323use pyo3:: exceptions:: { PyAttributeError , PyException , PyStopAsyncIteration , PyStopIteration } ;
@@ -81,15 +81,14 @@ impl<'py> IntoPyObject<'py> for Value {
8181 let t = DateTime :: < Tz > :: try_from ( self . 0 ) . map_err ( |e| {
8282 PyException :: new_err ( format ! ( "failed to convert timestamp: {e}" ) )
8383 } ) ?;
84- #[ cfg( Py_3_9 ) ]
84+ #[ cfg( feature = "cp38" ) ]
8585 {
86+ // chrono_tz -> PyDateTime isn't implemented for Python < 3.9 (no zoneinfo).
87+ let t: DateTime < FixedOffset > = t. with_timezone ( & t. offset ( ) . fix ( ) ) ;
8688 t. into_bound_py_any ( py) ?
8789 }
88- #[ cfg( not( Py_3_9 ) ) ]
90+ #[ cfg( not( feature = "cp38" ) ) ]
8991 {
90- // impl of IntoPyObject for chrono_tz::Tz is gated by #![cfg(all(Py_3_9, feature = "chrono-tz"))]
91- // Convert to a fixed-offset datetime so it works on Python < 3.9 (no zoneinfo).
92- let t: DateTime < FixedOffset > = t. with_timezone ( & t. offset ( ) . fix ( ) ) ;
9392 t. into_bound_py_any ( py) ?
9493 }
9594 }
You can’t perform that action at this time.
0 commit comments