Global

Members

(constant) DATA_DIR

Path to the CSV data bundled with this package. Resolved from the module's own location so it works from any working directory, both from source (`src/data`) and from the built output (`dist/../src/data`). On runtimes with no real filesystem - Cloudflare Workers being the one that matters here - nothing resolves and this falls back to `./src/data`, the relative default this package used before the constant existed. Workers consumers should pass an explicit directory instead: the CSVs are bundled as text modules, so the data lives at the bundle root (`/bundle/data`) rather than anywhere near the module.
Source:

Methods

fromDayNumber(dayNumber)

Inverse of toDayNumber; returns local midnight on that calendar day.
Parameters:
Name Type Description
dayNumber The number of days since the Unix epoch
Source:
Returns:
A `Date` at local midnight

getAllEntries(dataDir)

Reads all .csv files in the data directory and its subdirectories.
Parameters:
Name Type Description
dataDir The root data directory (default: './src/data')
Source:
Returns:
Array of all Entry objects

getEntries(filePath)

Parses a CSV file and returns an array of Entry objects. Automatically detects the format of each line.
Parameters:
Name Type Description
filePath The path to the CSV file
Source:
Returns:
Array of Entry objects

getEntriesBySource(entries, source)

Gets entries that came from a given data file or directory. Sources are recorded as forward-slash paths relative to the data directory, so `'sports/'` matches every sports file and `'cosmic/eclipses.csv'` matches exactly one.
Parameters:
Name Type Description
entries Array of entries to filter
source A source path or path prefix
Source:
Returns:
Array of entries whose source starts with the given prefix

getEntriesByType(entries, type)

Gets entries by type.
Parameters:
Name Type Description
entries Array of entries to filter
type The entry type to filter by
Source:
Returns:
Array of entries of the specified type

getEntriesInNextDays(entries, days, fromDate)

Gets entries that occur within the next N days.
Parameters:
Name Type Description
entries Array of entries to filter
days Number of days to look ahead
fromDate Starting date (default: today)
Source:
Returns:
Array of entries with their next occurrence dates

getEntriesInNextMonths(entries, months, fromDate)

Gets entries that occur within the next N months.
Parameters:
Name Type Description
entries Array of entries to filter
months Number of months to look ahead
fromDate Starting date (default: today)
Source:
Returns:
Array of entries with their next occurrence dates

getEntriesInNextWeeks(entries, weeks, fromDate)

Gets entries that occur within the next N weeks.
Parameters:
Name Type Description
entries Array of entries to filter
weeks Number of weeks to look ahead
fromDate Starting date (default: today)
Source:
Returns:
Array of entries with their next occurrence dates

getEntriesInNextYears(entries, years, fromDate)

Gets entries that occur within the next N years.
Parameters:
Name Type Description
entries Array of entries to filter
years Number of years to look ahead
fromDate Starting date (default: today)
Source:
Returns:
Array of entries with their next occurrence dates

getEntriesInRange(entries, startDate, endDate)

Gets every occurrence of every entry that falls inside a date window. Unlike the `getEntriesInNext*` helpers, which only ever consider each entry's single next occurrence, this expands recurring entries so a multi-year window yields one result per year.
Parameters:
Name Type Description
entries Array of entries to expand
startDate Start of the window (inclusive)
endDate End of the window (inclusive)
Source:
Returns:
Entry/date pairs sorted by date

getEntriesOnDate(entries, date)

Gets entries that occur on a specific date.
Parameters:
Name Type Description
entries Array of entries to filter
date The date to check
Source:
Returns:
Array of entries that occur on this date

getEntriesOnMonthDay(entries, month, day)

Gets entries whose anchor date is a specific month and day (any year). Only entries that own a fixed month/day are considered: ExactDateEntry, ExactDateWithYearEntry and OneTimeEntry. Entries whose date is computed (RelativeDateEntry, IntervalEntry, EasterEntry) or that span a window (DateRangeEntry) never match; use getEntriesOnDate for those.
Parameters:
Name Type Description
entries Array of entries to filter
month Month (1-12)
day Day of month
Source:
Returns:
Array of entries anchored to this month/day

isValidMonthDay(month, day)

Whether the month/day pair is a real calendar date. February is allowed 29 days because a recurring `02/29` entry is valid in leap years.
Parameters:
Name Type Description
month Month (1-12)
day Day of month
Source:
Returns:
true if the combination exists

parseCSVLine(line, source)

Parses a single CSV line into an Entry object. Supported formats, detected from the second field: | Format | Type | Example | | ----------------------------- | -------------------------- | ----------------------------- | | `MM/DD` | ExactDateEntry | `Pi Day,03/14` | | `MM/DD,YYYY` | ExactDateWithYearEntry | `Afghanistan,08/19,1919` | | `NWeekdayMonth` | RelativeDateEntry | `MLK Day,3MondayJan` | | `LWeekdayMonth` | RelativeDateEntry | `Memorial Day,LMondayMay` | | `YYYY-MM-DD` | OneTimeEntry | `Solar Eclipse,2026-08-12` | | `every:DAYS:YYYY-MM-DD` | IntervalEntry | `Halley,every:27758:1986-02-09` | | `range:MM/DD-MM/DD` | DateRangeEntry | `NFL Season,range:09/04-01/04` | | `easter[+-]N` | EasterEntry | `Good Friday,easter-2` | | `orthodox-easter[+-]N` | EasterEntry | `Orthodox Easter,orthodox-easter+0` | Names containing commas must be double-quoted.
Parameters:
Name Type Description
line The CSV line to parse
source Optional provenance recorded on the entry
Source:
Returns:
An Entry object or null if invalid

splitCSVFields(line)

Splits a CSV line into fields, honouring RFC 4180 double-quoted fields so that names containing commas (`"Nike, Inc's Birthday",01/25,1964`) survive. A doubled quote inside a quoted field is an escaped quote.
Parameters:
Name Type Description
line The raw CSV line
Source:
Returns:
The individual field values, unquoted and unescaped

toDayNumber(date)

Converts a `Date` to a whole-day number, ignoring the time-of-day and the local timezone offset. Two dates on the same local calendar day always produce the same number, which makes day arithmetic immune to DST shifts.
Parameters:
Name Type Description
date The date to convert
Source:
Returns:
The number of days since the Unix epoch