UNPKG

693 BPlain TextView Raw
1import type { DateLib } from "../index.js";
2import type { LabelOptions } from "../lib/dateLib.js";
3import { dateLib as defaultDateLib } from "../lib/index.js";
4import type { Modifiers } from "../types/index.js";
5
6/**
7 * The label for the day gridcell when the calendar is not interactive.
8 *
9 * @group Labels
10 * @see https://daypicker.dev/docs/translation#aria-labels
11 */
12export function labelGridcell(
13 date: Date,
14 /** The modifiers for the day. */
15 modifiers?: Modifiers,
16 options?: LabelOptions,
17 /** @ignore */
18 dateLib: DateLib = defaultDateLib
19) {
20 let label = dateLib.format(date, "PPPP", options);
21 if (modifiers?.today) {
22 label = `Today, ${label}`;
23 }
24 return label;
25}