PeriodService

Struct PeriodService 

Source
pub struct PeriodService<'a> { /* private fields */ }
Expand description

Service for budget period management

Implementations§

Source§

impl<'a> PeriodService<'a>

Source

pub fn new(settings: &'a Settings) -> Self

Create a new period service

Source

pub fn current_period(&self) -> BudgetPeriod

Get the current period based on user preferences

Source

pub fn period_for_date(&self, date: NaiveDate) -> BudgetPeriod

Get the period containing a specific date

Source

pub fn next_period(&self, period: &BudgetPeriod) -> BudgetPeriod

Get the next period after the given one

Source

pub fn previous_period(&self, period: &BudgetPeriod) -> BudgetPeriod

Get the previous period before the given one

Source

pub fn parse_or_current( &self, period_str: Option<&str>, ) -> EnvelopeResult<BudgetPeriod>

Parse a period string or get current period

Source

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”
Source

pub fn recent_periods(&self, count: usize) -> Vec<BudgetPeriod>

Get a list of periods for display (e.g., last 6 months)

Source

pub fn upcoming_periods(&self, count: usize) -> Vec<BudgetPeriod>

Get a list of upcoming periods (current + future)

Source

pub fn format_period(&self, period: &BudgetPeriod) -> String

Format a period for display

Source

pub fn format_period_friendly(&self, period: &BudgetPeriod) -> String

Format a period in a human-friendly way

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.