@@ -17,23 +17,23 @@ pub(crate) fn datetime_to_string(py_dt: &Bound<'_, PyDateTime>) -> PyResult<Stri
1717}
1818
1919pub ( crate ) fn datetime_to_seconds ( py_dt : & Bound < ' _ , PyDateTime > ) -> PyResult < f64 > {
20- pydatetime_as_datetime ( py_dt) . map ( |dt|
20+ pydatetime_as_datetime ( py_dt) . map ( |dt| {
2121 dt. date . timestamp ( ) as f64
22- + dt. time . hour as f64 * 3600.0
23- + dt. time . minute as f64 * 60.0
24- + dt. time . second as f64
25- + dt. time . microsecond as f64 / 1_000_000.0
26- )
22+ + f64 :: from ( dt. time . hour ) * 3600.0
23+ + f64 :: from ( dt. time . minute ) * 60.0
24+ + f64 :: from ( dt. time . second )
25+ + f64 :: from ( dt. time . microsecond ) / 1_000_000.0
26+ } )
2727}
2828
2929pub ( crate ) fn datetime_to_milliseconds ( py_dt : & Bound < ' _ , PyDateTime > ) -> PyResult < f64 > {
30- pydatetime_as_datetime ( py_dt) . map ( |dt|
30+ pydatetime_as_datetime ( py_dt) . map ( |dt| {
3131 dt. date . timestamp_ms ( ) as f64
32- + dt. time . hour as f64 * 3_600_000.0
33- + dt. time . minute as f64 * 60_000.0
34- + dt. time . second as f64 * 1_000.0
35- + dt. time . microsecond as f64 / 1_000.0
36- )
32+ + f64 :: from ( dt. time . hour ) * 3_600_000.0
33+ + f64 :: from ( dt. time . minute ) * 60_000.0
34+ + f64 :: from ( dt. time . second ) * 1_000.0
35+ + f64 :: from ( dt. time . microsecond ) / 1_000.0
36+ } )
3737}
3838
3939pub ( crate ) fn date_to_seconds ( py_date : & Bound < ' _ , PyDate > ) -> PyResult < f64 > {
@@ -53,16 +53,19 @@ pub(crate) fn time_to_string(py_time: &Bound<'_, PyTime>) -> PyResult<String> {
5353
5454pub ( crate ) fn time_to_seconds ( py_time : & Bound < ' _ , PyTime > ) -> PyResult < f64 > {
5555 pytime_as_time ( py_time, None ) . map ( |t| {
56- t. hour as f64 * 3600.0 + t. minute as f64 * 60.0 + t. second as f64 + t. microsecond as f64 / 1_000_000.0
56+ f64:: from ( t. hour ) * 3600.0
57+ + f64:: from ( t. minute ) * 60.0
58+ + f64:: from ( t. second )
59+ + f64:: from ( t. microsecond ) / 1_000_000.0
5760 } )
5861}
5962
6063pub ( crate ) fn time_to_milliseconds ( py_time : & Bound < ' _ , PyTime > ) -> PyResult < f64 > {
6164 pytime_as_time ( py_time, None ) . map ( |t| {
62- t. hour as f64 * 3_600_000.0
63- + t. minute as f64 * 60_000.0
64- + t. second as f64 * 1_000.0
65- + t. microsecond as f64 / 1_000.0
65+ f64 :: from ( t. hour ) * 3_600_000.0
66+ + f64 :: from ( t. minute ) * 60_000.0
67+ + f64 :: from ( t. second ) * 1_000.0
68+ + f64 :: from ( t. microsecond ) / 1_000.0
6669 } )
6770}
6871
0 commit comments