# Behavior traces — date-fns/date-fns

> Canonical page: https://codevetter.com/unpack/date-fns/behavior-traces

# Behavior traces — date-fns/date-fns

Scanned commit 717ce0a807ea4c6b540d015b5c408723175b2838 (2026-09-22). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The inspected flows cover an example startup, primary formatting and parsing actions, date arithmetic, subclass synchronization, and remote documentation persistence. Each trace follows concrete function calls and material branch conditions. Calculation flows end at returned values; the publisher ends at remote writes or deletions. These are source-derived execution traces, not observed runs.
- Example startup: main.tsx calls ReactDOM.createRoot(...).render → StrictMode → App → new Date → format(today, 'yyyy-MM-dd') → paragraph containing the returned string. — [pkgs/core/examples/vite/src/main.tsx#L1-L10](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/examples/vite/src/main.tsx#L1-L10) [pkgs/core/examples/vite/src/App.tsx#L4-L12](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/examples/vite/src/App.tsx#L4-L12)
- Formatting: format → getDefaultOptions → toDate → constructFrom → isValid → longFormatters → optional localize.preprocessor → protected-token check → formatters[token[0]] → join; invalid dates throw RangeError. — [pkgs/core/src/format/index.ts#L351-L380](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/format/index.ts#L351-L380) [pkgs/core/src/format/index.ts#L412-L441](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/format/index.ts#L412-L441) [pkgs/core/src/toDate/index.ts#L42-L50](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/toDate/index.ts#L42-L50) [pkgs/core/src/constructFrom/index.ts#L51-L59](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/constructFrom/index.ts#L51-L59)
- Parsing: parse expands tokens → looks up parsers → checks incompatibilities → Parser.run creates ValueSetter → rejects leftover non-whitespace → orders setters → validate/set; DateParser checks month/leap-year bounds before setting the day. — [pkgs/core/src/parse/index.ts#L403-L468](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/parse/index.ts#L403-L468) [pkgs/core/src/parse/index.ts#L494-L531](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/parse/index.ts#L494-L531) [pkgs/core/src/parse/_lib/Parser.ts#L10-L30](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/parse/_lib/Parser.ts#L10-L30) [pkgs/core/src/parse/_lib/parsers/DateParser.ts#L32-L53](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/parse/_lib/parsers/DateParser.ts#L32-L53)
- Zoned month addition: tz(zone) → TZDate.tz → addMonths → toDate with options.in → constructFrom(context, input) → destination-month-end calculation → clamp or setFullYear; NaN returns Invalid Date and zero returns the clone. — [pkgs/tz/src/tz/index.ts#L12-L13](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/tz/index.ts#L12-L13) [pkgs/tz/src/date/index.js#L7-L8](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/date/index.js#L7-L8) [pkgs/core/src/constructFrom/index.ts#L51-L59](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/constructFrom/index.ts#L51-L59) [pkgs/core/src/addMonths/index.ts#L63-L99](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/core/src/addMonths/index.ts#L63-L99)
- Target-zone setter: generated setHours writes internal.setUTCHours → syncFromInternal copies fields through native local setters → adjustToSystemTZ handles offset/DST differences → syncToInternal rebuilds the final wall-clock representation. — [pkgs/tz/src/date/mini.js#L135-L140](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/date/mini.js#L135-L140) [pkgs/tz/src/date/mini.js#L185-L204](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/date/mini.js#L185-L204) [pkgs/tz/src/date/mini.js#L425-L454](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/date/mini.js#L425-L454) [pkgs/tz/src/date/mini.js#L491-L504](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/tz/src/date/mini.js#L491-L504)
- UTC context: utc(value) converts the input to a timestamp → new UTCDate → UTCDateMini constructor sets time; local getter/setter names resolve to UTC methods and getTimezoneOffset returns zero. — [pkgs/utc/src/utc/index.ts#L11-L12](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/utc/src/utc/index.ts#L11-L12) [pkgs/utc/src/date/index.js#L16-L16](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/utc/src/date/index.js#L16-L16) [pkgs/utc/src/date/mini.js#L1-L29](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/utc/src/date/mini.js#L1-L29)
- Documentation publication: initializeApp → resolve/import config → getVersion validates package version → getFnPages/getMarkdownPages → concurrently update package versions, add a version summary, and commit a page batch → exit 0; errors exit 1. — [pkgs/docs/src/bin.ts#L21-L32](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/docs/src/bin.ts#L21-L32) [pkgs/docs/src/bin.ts#L63-L120](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/docs/src/bin.ts#L63-L120) [pkgs/docs/src/bin.ts#L123-L146](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/docs/src/bin.ts#L123-L146)
- Documentation rollback: after config/version loading, --rollback concurrently filters the package's version list, queries and removes matching version documents, and queries and removes matching page documents. — [pkgs/docs/src/bin.ts#L30-L61](https://github.com/date-fns/date-fns/blob/717ce0a807ea4c6b540d015b5c408723175b2838/pkgs/docs/src/bin.ts#L30-L61)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
