Expand description
Date and time utilities — business days, date ranges, holiday calendars, and formatting shortcuts.
§Example
use philiprehberger_date_utils::DateRange;
use chrono::NaiveDate;
let start = NaiveDate::from_ymd_opt(2026, 1, 1).unwrap();
let end = NaiveDate::from_ymd_opt(2026, 1, 31).unwrap();
let range = DateRange::new(start, end);Structs§
- Date
Range - An inclusive date range from
starttoend. - NoHoliday
Calendar - A calendar with no holidays — only weekends are non-business days.
- USFederal
Calendar - US Federal holiday calendar with weekend adjustment rules.
Traits§
- Holiday
Calendar - A calendar that can report which dates are holidays.
Functions§
- add_
business_ days - Add (or subtract) business days to a date, skipping weekends and holidays.
- business_
days_ between - Count the number of business days between
start(inclusive) andend(exclusive). - end_
of_ month - Returns the last day of the month containing
date. - end_
of_ quarter - Returns the last day of the quarter containing
date. - fiscal_
year - Returns the fiscal year for a given date with a custom fiscal-year start month.
- format_
iso - Format a date as “2026-03-19”.
- format_
long - Format a date as “March 19, 2026”.
- format_
short - Format a date as “Mar 19, 2026”.
- is_
business_ day - Returns
trueif the date is a business day (not a weekend, not a holiday). - next_
business_ day - Returns the next business day strictly after
date. - quarter
- Returns the quarter (1-4) for the given date.
- start_
of_ month - Returns the first day of the month containing
date. - start_
of_ quarter - Returns the first day of the quarter containing
date. - years_
between - Returns the number of full years between two dates (age-style calculation).