Voile.Schema.System.LibHolidays (Voile v0.1.27)

Copy Markdown View Source

Context module for managing library holidays and weekly schedules for business day calculations.

This module provides functions to:

  • Manage holidays (specific dates like Christmas, Independence Day)
  • Configure weekly schedules (which days of the week are business days)
  • Calculate business days excluding configured non-business days and holidays
  • Import common holidays
  • Validate holiday and schedule configurations

The system supports two types of entries:

  • schedule_type: "holiday" - Specific holiday dates
  • schedule_type: "schedule" - Weekly recurring schedule patterns

This unified approach allows flexible customization of:

  • Which days of the week are business days (not just Mon-Fri)
  • Specific holiday dates that override normal schedule
  • Different types of holidays (public, library, custom)

Summary

Functions

Add business days to a date, skipping weekends and holidays.

Calculate business days between two dates, excluding weekends and holidays.

Returns an %Ecto.Changeset{} for tracking holiday changes.

Creates a holiday.

Creates a new schedule configuration.

Deletes a holiday.

Deletes a schedule configuration.

Get business days for the current week.

Get schedule configuration for a specific day of week.

Gets a single holiday.

Get holiday statistics for reporting.

Get all holidays within a date range.

Get non-business days for the current week.

Get upcoming holidays for the next N days.

Get the current weekly schedule configuration.

Check if library operates on a specific day of week based on schedule.

Check if a given date is a holiday (weekend or custom holiday).

Check if a given date is a weekend.

Returns the list of all holidays.

Returns the list of holidays with pagination.

Returns the list of weekly schedule configurations.

Calculate the next business day from a given date.

Set up default weekly schedule (Monday-Friday business, Saturday-Sunday non-business).

Update a specific day's business status in the weekly schedule.

Updates a holiday.

Updates a schedule configuration.

Functions

add_business_days(date, days)

Add business days to a date, skipping weekends and holidays.

business_days_between(start_date, end_date, unit_id \\ nil)

Calculate business days between two dates, excluding weekends and holidays.

change_holiday(holiday, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking holiday changes.

create_holiday(attrs \\ %{})

Creates a holiday.

create_schedule(attrs \\ %{})

Creates a new schedule configuration.

delete_holiday(holiday)

Deletes a holiday.

delete_schedule(schedule)

Deletes a schedule configuration.

get_business_days()

Get business days for the current week.

get_day_schedule(day_of_week)

Get schedule configuration for a specific day of week.

get_holiday!(id)

Gets a single holiday.

get_holiday_stats(unit_id \\ nil)

Get holiday statistics for reporting.

get_holidays_in_range(start_date, end_date)

Get all holidays within a date range.

get_non_business_days()

Get non-business days for the current week.

get_upcoming_holidays(days \\ 30)

Get upcoming holidays for the next N days.

get_weekly_schedule(unit_id \\ nil)

Get the current weekly schedule configuration.

is_business_day?(day_of_week)

Check if library operates on a specific day of week based on schedule.

is_holiday?(date, unit_id \\ nil)

Check if a given date is a holiday (weekend or custom holiday).

is_weekend?(date)

Check if a given date is a weekend.

list_holidays(unit_id \\ nil)

Returns the list of all holidays.

list_holidays_paginated(page \\ 1, per_page \\ 20, unit_id \\ nil)

Returns the list of holidays with pagination.

list_schedule_configurations()

Returns the list of weekly schedule configurations.

next_business_day(date)

Calculate the next business day from a given date.

setup_default_weekly_schedule(unit_id \\ nil)

Set up default weekly schedule (Monday-Friday business, Saturday-Sunday non-business).

update_day_schedule(day_of_week, is_business_day, description \\ nil, unit_id \\ nil)

Update a specific day's business status in the weekly schedule.

update_holiday(holiday, attrs)

Updates a holiday.

update_schedule(schedule, attrs)

Updates a schedule configuration.