| Title: | Deterministic Calendar Grids and Date Planning Utilities |
|---|---|
| Description: | Tools for generating deterministic month, year, and date-range calendar structures from base R dates. Configurable week starts, fixed and compact month grids, adjacent-month cells, ISO week metadata, calendar boundaries, and bounded recurrence helpers support reporting, dashboards, scheduling interfaces, tests, and other applications that separate calendar structure from rendering. |
| Authors: | Mateo Pedersen [aut, cre] |
| Maintainer: | Mateo Pedersen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-11 11:51:01 UTC |
| Source: | https://github.com/Beta-Calendar/betaCalendarsR |
Reports year and month endpoints, Gregorian leap-year facts, and ISO week-year crossover dates.
calendar_boundaries(year)calendar_boundaries(year)
year |
Four-digit calendar year. |
A list of year dates, month endpoint tables, leap-year information, and ISO crossover dates.
calendar_boundaries(2027)$iso_crossover_datescalendar_boundaries(2027)$iso_crossover_dates
Includes the month containing each endpoint of an inclusive date interval.
calendar_sequence(from, to)calendar_sequence(from, to)
from |
First date, inclusive. |
to |
Last date, inclusive. |
A data frame with one row per touched month and its first date.
calendar_sequence(as.Date("2026-12-20"), as.Date("2027-02-10"))calendar_sequence(as.Date("2026-12-20"), as.Date("2027-02-10"))
Summarizes month lengths and the row counts used by calendar grids.
calendar_summary(year, month = NULL, week_start = "monday", fixed_rows = TRUE)calendar_summary(year, month = NULL, week_start = "monday", fixed_rows = TRUE)
year |
Four-digit calendar year. |
month |
Optional month; omit to return all twelve. |
week_start |
First weekday in each row. |
fixed_rows |
Whether each grid uses six rows. |
A data frame with one row per requested month.
calendar_summary(2027, 2)calendar_summary(2027, 2)
Returns every date between two inclusive Date endpoints and adds calendar coordinates.
date_range_grid(from, to, week_start = "monday")date_range_grid(from, to, week_start = "monday")
from |
First date, inclusive. |
to |
Last date, inclusive. |
week_start |
First weekday used for row and column coordinates. |
A data frame with one row for every consecutive date.
dates <- date_range_grid(as.Date("2026-12-30"), as.Date("2027-01-03")) dates[c("date", "year", "month", "weekday", "iso_week_year")]dates <- date_range_grid(as.Date("2026-12-30"), as.Date("2027-01-03")) dates[c("date", "year", "month", "weekday", "iso_week_year")]
Returns the last Monday-Friday date, or the final occurrence of a selected weekday.
last_weekday(year, month, weekday = NULL)last_weekday(year, month, weekday = NULL)
year |
Four-digit calendar year. |
month |
Month number from 1 through 12. |
weekday |
Optional full English weekday name. |
A Date.
last_weekday(2027, 1) last_weekday(2027, 1, "monday")last_weekday(2027, 1) last_weekday(2027, 1, "monday")
Creates complete calendar weeks for one month. Adjacent-month dates keep their positions so weekday columns remain stable.
month_grid(year, month, week_start = "monday", fixed_rows = TRUE, overflow = TRUE)month_grid(year, month, week_start = "monday", fixed_rows = TRUE, overflow = TRUE)
year |
Four-digit calendar year. |
month |
Month number from 1 through 12. |
week_start |
First weekday in each row; any full weekday name is accepted. |
fixed_rows |
If true, return six complete rows; otherwise return the minimum complete number of weeks. |
overflow |
If false, adjacent-month cells remain in the grid but have visible set to false. |
A data frame with one row per date cell, including date, calendar, ISO week, row/column, visibility, and boundary fields.
january <- month_grid(2027, 1, week_start = "monday") nrow(january) sum(january$in_month)january <- month_grid(2027, 1, week_start = "monday") nrow(january) sum(january$in_month)
Computes a selected occurrence without silently rolling an absent fifth weekday into the following month.
nth_weekday(year, month, weekday, n = 1L)nth_weekday(year, month, weekday, n = 1L)
year |
Four-digit calendar year. |
month |
Month number from 1 through 12. |
weekday |
Full English weekday name. |
n |
Occurrence number from 1 through 5. |
A Date, or NA when that occurrence does not exist.
nth_weekday(2027, 1, "monday", 1)nth_weekday(2027, 1, "monday", 1)
Evaluates a weekly, monthly, nth-weekday, last-weekday, or annual date rule only within an explicit inclusive range.
recurrence_dates( from, to, frequency = c("weekly", "monthly", "nth_weekday", "last_weekday", "annual"), weekday = NULL, day = NULL, n = 1L, month_day = NULL, missing = c("skip", "clamp") )recurrence_dates( from, to, frequency = c("weekly", "monthly", "nth_weekday", "last_weekday", "annual"), weekday = NULL, day = NULL, n = 1L, month_day = NULL, missing = c("skip", "clamp") )
from |
First date, inclusive. |
to |
Last date, inclusive. |
frequency |
Recurrence kind. |
weekday |
Full English weekday name where used. |
day |
Day number for monthly rules. |
n |
Occurrence number for nth-weekday rules. |
month_day |
Annual month/day in MM-DD form. |
missing |
Skip or clamp a missing monthly or annual date. |
A date-ordered data frame with one row per recurrence and calendar metadata.
recurrence_dates(as.Date("2027-01-01"), as.Date("2027-01-31"), frequency = "weekly", weekday = "monday")recurrence_dates(as.Date("2027-01-01"), as.Date("2027-01-31"), frequency = "weekly", weekday = "monday")
Checks date, row, and column invariants for a calendar data frame.
validate_calendar_grid(x)validate_calendar_grid(x)
x |
A data frame returned by month_grid, year_grid, or date_range_grid. |
TRUE invisibly when valid; otherwise raises an informative error.
validate_calendar_grid(month_grid(2027, 1))validate_calendar_grid(month_grid(2027, 1))
Creates twelve ordered month grids with a shared week convention.
year_grid( year, week_start = "monday", fixed_rows = TRUE, overflow = TRUE, as = c("data.frame", "list") )year_grid( year, week_start = "monday", fixed_rows = TRUE, overflow = TRUE, as = c("data.frame", "list") )
year |
Four-digit calendar year. |
week_start |
First weekday in each row. |
fixed_rows |
Whether each month uses six rows. |
overflow |
Whether adjacent-month cells are visible. |
as |
Return a combined data frame or named list of month data frames. |
A January-to-December data frame or named list.
year <- year_grid(2027) table(year$month) months <- year_grid(2027, as = "list")year <- year_grid(2027) table(year$month) months <- year_grid(2027, as = "list")