BetaCalendars Calendar Layout Algebra
betacalendars-calendar-layout is a pure Haskell library for deterministic
Gregorian month topology, seven week origins, natural and fixed six-week grids,
undated planning grids, and physical print-layout measurements. It is useful
without any BetaCalendars service and performs no network access.
Install
Add the package to a Cabal project:
build-depends: betacalendars-calendar-layout
The runtime dependency surface is intentionally small: base and time.
Quick start
import BetaCalendars.CalendarLayout
januaryTopology :: MonthTopology
januaryTopology = monthTopology (Year 2027) January MondayStart
sundayJanuary :: MonthGrid
sundayJanuary = buildMonthGrid
(Year 2027) January SundayStart FixedSixWeeks IncludeAdjacentDates
NaturalRows uses the actual four-to-six row month shape. FixedSixWeeks
always contains exactly 42 cells. Set BlankAdjacentCells to keep adjacent
dates out of the visible grid while retaining explicit EmptyCell semantics.
Examples
January 2027 topology:
monthTopology (Year 2027) January MondayStart
Compare week origins:
monthTopology (Year 2027) January MondayStart
monthTopology (Year 2027) January SundayStart
Fixed 42-cell grid:
length (gridCells (buildMonthGrid (Year 2027) January SundayStart
FixedSixWeeks IncludeAdjacentDates)) == 42
A4 portrait metrics and an undated 6 × 7 planner:
import BetaCalendars.CalendarLayout.Blank
import BetaCalendars.CalendarLayout.Paper
layoutMetrics (defaultLayoutSpec A4 Portrait 6)
blankGrid SixWeeks
Runnable versions of these examples are in examples/.
Computed 2027 topology
The table is derived from the Gregorian calendar model. Weekday labels and row
counts are computed, not stored as hand-entered month data. “Printable
reference” links point to human-readable Beta Calendars pages.
| Month | Days | First weekday | Last weekday | Monday-first rows | Sunday-first rows | Printable reference |
|---|---:|---|---|---:|---:|
| January | 31 | Friday | Sunday | 5 | 6 | January Calendar |
| February | 28 | Monday | Sunday | 4 | 5 | February Calendar |
| March | 31 | Monday | Wednesday | 5 | 5 | March Calendar |
| April | 30 | Thursday | Friday | 5 | 5 | April Calendar |
| May | 31 | Saturday | Monday | 6 | 6 | May Calendar |
| June | 30 | Tuesday | Wednesday | 5 | 5 | June Calendar |
| July | 31 | Thursday | Saturday | 5 | 5 | July Calendar |
| August | 31 | Sunday | Tuesday | 6 | 5 | August Calendar |
| September | 30 | Wednesday | Thursday | 5 | 5 | September Calendar |
| October | 31 | Friday | Sunday | 5 | 6 | October Calendar |
| November | 30 | Monday | Tuesday | 5 | 5 | November Calendar |
| December | 31 | Wednesday | Friday | 5 | 5 | December Calendar |
Human-readable 2027 calendar references
The library calculates calendar topology independently from Gregorian civil
rules. The following Beta Calendars pages are human-readable printable
references for visual comparison with the computed month structures.
Modules
BetaCalendars.CalendarLayout: curated high-level API.
.Civil: Gregorian year, month, date and weekday operations.
.WeekStart: week-origin rotation and offsets.
.Grid: natural/fixed month grids and topology signatures.
.Paper: millimetres, paper sizes, margins and layout metrics.
.Blank: undated 5 × 7 and 6 × 7 planning grids.
.Year2027: computed January–December 2027 fixtures.
.Boundary2027: November 2026 through February 2027 fixtures.
.Validation: structured validation diagnostics and the 1900–2100 matrix.
Validation
Run cabal check, cabal build all, cabal test all, and cabal haddock all.
The deterministic test suite checks every month from 1900 through 2100 for all
seven week starts and both grid modes, along with leap-year boundaries,
paper-size/orientation combinations, blank grids, and the 2026–2027 boundary.
License
MIT. See LICENSE.