From db51f7f103bbbd6c91c8f47d75b3482ef8939691 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 17 Dec 2023 15:32:20 +0100 Subject: Adding upstream version 3.0.0. Signed-off-by: Daniel Baumann --- rust/src/python/types/interval.rs | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 rust/src/python/types/interval.rs (limited to 'rust/src/python/types/interval.rs') diff --git a/rust/src/python/types/interval.rs b/rust/src/python/types/interval.rs new file mode 100644 index 0000000..7137493 --- /dev/null +++ b/rust/src/python/types/interval.rs @@ -0,0 +1,46 @@ +use pyo3::prelude::*; + +use pyo3::types::PyDelta; + +#[pyclass(extends=PyDelta)] +#[derive(Default)] +pub struct Interval { + pub days: i32, + pub seconds: i32, + pub microseconds: i32, +} + +#[pymethods] +impl Interval { + #[new] + #[pyo3(signature = (days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0))] + pub fn new( + py: Python, + days: Option, + seconds: Option, + microseconds: Option, + milliseconds: Option, + minutes: Option, + hours: Option, + weeks: Option, + ) -> PyResult { + println!("{} days", 31); + PyDelta::new( + py, + days.unwrap_or(0), + seconds.unwrap_or(0), + microseconds.unwrap_or(0), + true, + )?; + + let f = Ok(Self { + days: days.unwrap_or(0), + seconds: seconds.unwrap_or(0), + microseconds: microseconds.unwrap_or(0), + }); + + println!("{} days", 31); + + f + } +} -- cgit v1.2.3