pub enum Frequency {
BusDays {
number: i32,
calendar: Calendar,
},
CalDays {
number: i32,
},
Months {
number: i32,
roll: Option<RollDay>,
},
Zero {},
}
Expand description
A frequency for generating unadjusted scheduling periods.
Variants§
BusDays
A set number of business days, defined by a Calendar
, which can only align with a
business day as defined by that Calendar
.
CalDays
A set number of calendar days, which can align with any unadjusted date. To achieve a
Weeks
variant use an appropriate number
of days.
Months
A set number of calendar months, with a potential RollDay
.
To achieve a Years
variant use an appropriate number
of months.
Zero
Only ever defining one single period, and which can align with any unadjusted date.
Implementations§
Source§impl Frequency
impl Frequency
Sourcepub fn try_vec_from(
&self,
udates: &Vec<NaiveDateTime>,
) -> Result<Vec<Frequency>, PyErr>
pub fn try_vec_from( &self, udates: &Vec<NaiveDateTime>, ) -> Result<Vec<Frequency>, PyErr>
Get a vector of possible, fully specified Frequency
variants for a series of unadjusted dates.
§Notes
This method exists primarily to resolve cases when the RollDay
on a
Frequency::Months
variant is None
, and there are multiple possibilities. In this case
the method RollDay::vec_from
is called internally.
If the Frequency
variant does not align with any of the provided unadjusted dates this
will return an error.
§Examples
// The RollDay is unspecified here
let f = Frequency::Months{number: 3, roll: None};
let result = f.try_vec_from(&vec![ndt(2024, 2, 29)]);
assert_eq!(result.unwrap(), vec![
Frequency::Months{number: 3, roll: Some(RollDay::Day(29))},
Frequency::Months{number: 3, roll: Some(RollDay::Day(30))},
Frequency::Months{number: 3, roll: Some(RollDay::Day(31))},
]);
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Frequency
impl<'de> Deserialize<'de> for Frequency
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 Frequency
impl<'py> IntoPyObject<'py> for Frequency
Source§impl PyClassBaseType for Frequency
impl PyClassBaseType for Frequency
type LayoutAsBase = PyClassObject<Frequency>
type BaseNativeType = <Frequency as PyClassImpl>::BaseNativeType
type Initializer = PyClassInitializer<Frequency>
type PyClassMutability = <Frequency as PyClassImpl>::PyClassMutability
Source§impl PyClassImpl for Frequency
impl PyClassImpl for Frequency
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<Frequency>
type ThreadChecker = SendablePyClass<Frequency>
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<Frequency> for PyClassImplCollector<Frequency>
impl PyClassNewTextSignature<Frequency> for PyClassImplCollector<Frequency>
fn new_text_signature(self) -> Option<&'static str>
Source§impl PyMethods<Frequency> for PyClassImplCollector<Frequency>
impl PyMethods<Frequency> for PyClassImplCollector<Frequency>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Frequency
impl PyTypeInfo for Frequency
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.Source§impl Scheduling for Frequency
impl Scheduling for Frequency
Source§fn try_udate(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
fn try_udate(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
Validate if an unadjusted date aligns with the specified Frequency variant.
§Notes
This method will return error in one of two cases:
- The
udate
does not align with the fully defined variant. - The variant is not fully defined (e.g. a
Months
variant is missing aRollDay
) and cannot make the determination.
Therefore,
- For a CalDays variant or Zero variant, any
udate
is valid. - For a BusDays variant,
udate
must be a business day. - For a Months variant,
udate
must align with the RollDay. If no RollDay is specified an error will always be returned.
§Examples
let result = Frequency::Months{number: 1, roll: Some(RollDay::IMM{})}.try_udate(&ndt(2025, 7, 16));
assert!(result.is_ok());
let result = Frequency::Months{number: 1, roll: None}.try_udate(&ndt(2025, 7, 16));
assert!(result.is_err());
Source§fn next(&self, date: &NaiveDateTime) -> NaiveDateTime
fn next(&self, date: &NaiveDateTime) -> NaiveDateTime
date
. Read moreSource§fn previous(&self, date: &NaiveDateTime) -> NaiveDateTime
fn previous(&self, date: &NaiveDateTime) -> NaiveDateTime
date
. Read moreSource§fn try_uregular(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> Result<Vec<NaiveDateTime>, PyErr>
fn try_uregular( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> Result<Vec<NaiveDateTime>, PyErr>
Source§fn try_unext(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
fn try_unext(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
Source§fn try_uprevious(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
fn try_uprevious(&self, udate: &NaiveDateTime) -> Result<NaiveDateTime, PyErr>
Source§fn try_uregular_from_unext(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> Result<Vec<NaiveDateTime>, PyErr>
fn try_uregular_from_unext( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> Result<Vec<NaiveDateTime>, PyErr>
Source§fn is_regular_period(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_regular_period( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_short_front_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_short_front_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_long_front_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_long_front_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_short_back_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_short_back_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_long_back_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_long_back_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_front_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_front_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn is_back_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
) -> bool
fn is_back_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, ) -> bool
Source§fn try_infer_ufront_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
short: bool,
) -> Result<Option<NaiveDateTime>, PyErr>
fn try_infer_ufront_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, short: bool, ) -> Result<Option<NaiveDateTime>, PyErr>
Source§fn try_infer_uback_stub(
&self,
ueffective: &NaiveDateTime,
utermination: &NaiveDateTime,
short: bool,
) -> Result<Option<NaiveDateTime>, PyErr>
fn try_infer_uback_stub( &self, ueffective: &NaiveDateTime, utermination: &NaiveDateTime, short: bool, ) -> Result<Option<NaiveDateTime>, PyErr>
Source§fn periods_per_annum(&self) -> f64
fn periods_per_annum(&self) -> f64
impl StructuralPartialEq for Frequency
Auto Trait Implementations§
impl Freeze for Frequency
impl RefUnwindSafe for Frequency
impl Send for Frequency
impl Sync for Frequency
impl Unpin for Frequency
impl UnwindSafe for Frequency
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<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.