pub struct PeriodService<'a> { /* private fields */ }Expand description
Service for budget period management
Implementations§
Source§impl<'a> PeriodService<'a>
impl<'a> PeriodService<'a>
Sourcepub fn current_period(&self) -> BudgetPeriod
pub fn current_period(&self) -> BudgetPeriod
Get the current period based on user preferences
Sourcepub fn period_for_date(&self, date: NaiveDate) -> BudgetPeriod
pub fn period_for_date(&self, date: NaiveDate) -> BudgetPeriod
Get the period containing a specific date
Sourcepub fn next_period(&self, period: &BudgetPeriod) -> BudgetPeriod
pub fn next_period(&self, period: &BudgetPeriod) -> BudgetPeriod
Get the next period after the given one
Sourcepub fn previous_period(&self, period: &BudgetPeriod) -> BudgetPeriod
pub fn previous_period(&self, period: &BudgetPeriod) -> BudgetPeriod
Get the previous period before the given one
Sourcepub fn parse_or_current(
&self,
period_str: Option<&str>,
) -> EnvelopeResult<BudgetPeriod>
pub fn parse_or_current( &self, period_str: Option<&str>, ) -> EnvelopeResult<BudgetPeriod>
Parse a period string or get current period
Sourcepub fn parse(&self, s: &str) -> EnvelopeResult<BudgetPeriod>
pub fn parse(&self, s: &str) -> EnvelopeResult<BudgetPeriod>
Parse a period string according to user preferences
Formats supported:
- Monthly: “2025-01”, “January 2025”, “Jan”, “last”, “next”
- Weekly: “2025-W03”, “W3”, “last”, “next”
- Date range: “2025-01-01..2025-01-14”
Sourcepub fn recent_periods(&self, count: usize) -> Vec<BudgetPeriod>
pub fn recent_periods(&self, count: usize) -> Vec<BudgetPeriod>
Get a list of periods for display (e.g., last 6 months)
Sourcepub fn upcoming_periods(&self, count: usize) -> Vec<BudgetPeriod>
pub fn upcoming_periods(&self, count: usize) -> Vec<BudgetPeriod>
Get a list of upcoming periods (current + future)
Sourcepub fn format_period(&self, period: &BudgetPeriod) -> String
pub fn format_period(&self, period: &BudgetPeriod) -> String
Format a period for display
Sourcepub fn format_period_friendly(&self, period: &BudgetPeriod) -> String
pub fn format_period_friendly(&self, period: &BudgetPeriod) -> String
Format a period in a human-friendly way
Sourcepub fn is_current(&self, period: &BudgetPeriod) -> bool
pub fn is_current(&self, period: &BudgetPeriod) -> bool
Check if a period is the current period
Auto Trait Implementations§
impl<'a> Freeze for PeriodService<'a>
impl<'a> RefUnwindSafe for PeriodService<'a>
impl<'a> Send for PeriodService<'a>
impl<'a> Sync for PeriodService<'a>
impl<'a> Unpin for PeriodService<'a>
impl<'a> UnwindSafe for PeriodService<'a>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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