CodeVetter · Repo Unpack · Data flow
date-fns/date-fns
Date inputs enter through typed arguments and are normalized into fresh objects before calculation. Context functions and construction hooks determine the date class and time zone used by downstream accessors. Formatting produces strings, parsing builds dates through ordered setters, and enumeration produces arrays of cloned dates. Documentation processing is a separate flow from local files and reflection data into remote collections.
- DateArg accepts a Date subtype, number, or string; toDate forwards the input and optional context to constructFrom.
- constructFrom prioritizes a supplied function, then constructFromSymbol, then a Date instance's constructor, and finally native Date construction.
- normalizeDates binds a constructor context using the explicit context or first object argument, then maps every input through it; normalizeInterval applies this to both endpoints.
- format resolves locale and week defaults, normalizes the date, expands long tokens into parts, optionally preprocesses them, and joins formatter results.
- Parser.run converts a parsed value into a ValueSetter and remaining text; parse retains one setter per priority, validates it against the evolving date, and merges returned flags.
- TZDateMini stores the instant on itself and wall-clock fields on internal; timestamp writes call syncToInternal, while local setters call syncFromInternal and adjustToSystemTZ.
- Global default options live in a module variable; setDefaultOptions copies existing own properties, merges new values, deletes keys set to undefined, and replaces the state object.
- Documentation inputs resolve relative to the imported config; TypeDoc references become serialized function pages and Markdown files become static pages before package metadata, version summaries, and page records are written.