CodeVetter · Repo Unpack · Extension points
date-fns/date-fns
Extensions plug into typed date construction, locale objects, token tables, and code-generation inputs. Public function discovery drives export maps and indices rather than requiring every output to be hand-maintained. Parser classes expose explicit compatibility and priority contracts. Documentation has its own configuration interface for additional static pages, categories, and reflection overrides.
- Custom Date subclasses can implement ConstructableDate's constructFromSymbol hook; constructFrom also accepts a context factory directly, and TZDate implements the shared constructDateFrom symbol.
- New public functions enter generator discovery through listFns; indices.ts generates the root index, FP index, locale index, TypeDoc configuration, and workspace/published export maps.
- Parsing tokens plug into the parsers table through Parser subclasses that declare incompatibleTokens, priority, optional subPriority, parse, validate, and set behavior.
- Formatter behavior plugs into the formatters table keyed by token letter; handlers receive date, full token, localize functions, and week/locale options, and format reexports formatter tables for downstream libraries.
- A locale supplies formatDistance, formatLong, formatRelative, localize, match, and week options; the contribution guide recommends copying an existing locale and replacing its data using CLDR as a reference.
- Locale-specific token rewriting can use localize.preprocessor, which receives the normalized date and classified FormatPart array before final formatting.
- FP generation derives arity and options variants from reflection signatures and excludes @pure false functions; generated wrappers delegate to the shared convertToFP implementation.
- DateFnsDocs.Config extends publication inputs through package/json paths, ordered categories, static files, and kindsMap overrides; readRefsFromJSON uses overrides to classify constants and assign categories.