pub enum RollDay {
Day(u32),
IMM(),
}
Expand description
A roll-day used with a Frequency::Months
variant.
Variants§
Day(u32)
A day of the month in [1, 31].
IMM()
The third Wednesday of any month (equivalent to Imm::Wed3)
Implementations§
Source§impl RollDay
impl RollDay
Sourcepub fn vec_from(udates: &Vec<NaiveDateTime>) -> Vec<Self>
pub fn vec_from(udates: &Vec<NaiveDateTime>) -> Vec<Self>
Get all possible RollDay
variants implied from one or more unadjusted dates.
§Notes
Each date is analysed in turn. The order of RollDay
construction for each date is:
- Get the integer roll-day of the date.
- Get additional end-of-month related integer roll-days for short calendar months if necessary.
- Get non-numeric roll-days if date aligns with those, ordered by the underlying enum order.
When multiple dates are checked the results for a subsequent date is added to the prior
results under the [IndexSet.intersection
] ordering rules.
Any date will always return at least one RollDay and the first one will always be equivalent to an integer variant whose day equals the calendar day of the first date.
§Examples
let result = RollDay::vec_from(&vec![ndt(2024, 2, 29), ndt(2024, 3, 20), ndt(2024, 3, 31)]);
assert_eq!(result, vec![
RollDay::Day(29),
RollDay::Day(30),
RollDay::Day(31),
RollDay::Day(20),
RollDay::IMM(),
]);
Sourcepub fn try_udate(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
pub fn try_udate(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
Sourcepub fn try_uadd(
&self,
udate: &NaiveDateTime,
months: i32,
) -> Result<NaiveDateTime, PyErr>
pub fn try_uadd( &self, udate: &NaiveDateTime, months: i32, ) -> Result<NaiveDateTime, PyErr>
Add a given number of months to an unadjusted date under the RollDay definition.
§Notes
This method will also check the given udate
using RollDay::try_udate.
§Examples
let date = RollDay::IMM().try_uadd(&ndt(2024, 3, 20), 3);
assert_eq!(ndt(2024, 6, 19), date.unwrap());
let date = RollDay::Day(31).try_uadd(&ndt(2024, 3, 15), 3);
assert!(date.is_err());
Sourcepub fn uadd(&self, udate: &NaiveDateTime, months: i32) -> NaiveDateTime
pub fn uadd(&self, udate: &NaiveDateTime, months: i32) -> NaiveDateTime
Sourcepub fn try_from_ym(&self, year: i32, month: u32) -> Result<NaiveDateTime, PyErr>
pub fn try_from_ym(&self, year: i32, month: u32) -> Result<NaiveDateTime, PyErr>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RollDay
impl<'de> Deserialize<'de> for RollDay
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'py> IntoPyObject<'py> for RollDay
impl<'py> IntoPyObject<'py> for RollDay
Source§impl PyClassBaseType for RollDay
impl PyClassBaseType for RollDay
type LayoutAsBase = PyClassObject<RollDay>
type BaseNativeType = <RollDay as PyClassImpl>::BaseNativeType
type Initializer = PyClassInitializer<RollDay>
type PyClassMutability = <RollDay as PyClassImpl>::PyClassMutability
Source§impl PyClassImpl for RollDay
impl PyClassImpl for RollDay
Source§const IS_BASETYPE: bool = true
const IS_BASETYPE: bool = true
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§type ThreadChecker = SendablePyClass<RollDay>
type ThreadChecker = SendablePyClass<RollDay>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<RollDay> for PyClassImplCollector<RollDay>
impl PyClassNewTextSignature<RollDay> for PyClassImplCollector<RollDay>
fn new_text_signature(self) -> Option<&'static str>
Source§impl PyMethods<RollDay> for PyClassImplCollector<RollDay>
impl PyMethods<RollDay> for PyClassImplCollector<RollDay>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for RollDay
impl PyTypeInfo for RollDay
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.impl Copy for RollDay
impl Eq for RollDay
impl StructuralPartialEq for RollDay
Auto Trait Implementations§
impl Freeze for RollDay
impl RefUnwindSafe for RollDay
impl Send for RollDay
impl Sync for RollDay
impl Unpin for RollDay
impl UnwindSafe for RollDay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self
into a Python object. Read more§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.