# Extension points — iamkun/dayjs

> Canonical page: https://codevetter.com/unpack/dayjs/extension-points

# Extension points — iamkun/dayjs

Scanned commit 436bde0bcded312781cbe45dc2b0ef079a36d8e3 (2026-09-15). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The main extension contract is a plugin function that can modify the class, factory, and shared utilities. Locale objects supply data and callbacks independently of the core bundle. TypeScript declarations extend public interfaces separately from implementation. Build discovery automatically packages conventionally placed modules, making file naming and registration conventions part of the extension surface.
- New plugins implement (option, DayjsClass, dayjsFactory), install through dayjs.extend, and can add instance or factory methods; installation is guarded by the plugin function's $i marker. — [src/index.js#L448-L453](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/index.js#L448-L453) [test/plugin.test.js#L4-L13](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/test/plugin.test.js#L4-L13) [types/index.d.ts#L418-L420](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/types/index.d.ts#L418-L420)
- Existing-method extensions capture the previous implementation and delegate with the current instance; localizedFormat wraps format, UTC wraps parse/init, and isoWeek intercepts startOf only for its unit. — [src/plugin/localizedFormat/index.js#L5-L12](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/localizedFormat/index.js#L5-L12) [src/plugin/utc/index.js#L43-L68](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/utc/index.js#L43-L68) [src/plugin/isoWeek/index.js#L40-L49](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/isoWeek/index.js#L40-L49)
- $utils exposes shared helpers under short keys; the core adds locale resolution, Dayjs recognition, and metadata-preserving wrapper functions to the imported utility object. — [src/utils.js#L48-L55](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/utils.js#L48-L55) [src/index.js#L50-L61](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/index.js#L50-L61) [src/index.js#L110-L113](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/index.js#L110-L113)
- Locale modules register named objects with dayjs.locale(locale, null, true); supported hooks include ordinal, meridiem, relative-time functions, and preparse/postformat callbacks. — [src/locale/zh-cn.js#L11-L17](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/locale/zh-cn.js#L11-L17) [src/locale/zh-cn.js#L48-L67](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/locale/zh-cn.js#L48-L67) [src/locale/sl.js#L87-L106](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/locale/sl.js#L87-L106) [src/plugin/preParsePostFormat/index.js#L3-L22](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/preParsePostFormat/index.js#L3-L22)
- Plugin options expose targeted customization: customParseFormat accepts parseTwoDigitYear, relativeTime accepts thresholds and rounding, and calendar accepts per-call format strings or functions. — [src/plugin/customParseFormat/index.js#L217-L220](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/customParseFormat/index.js#L217-L220) [src/plugin/relativeTime/index.js#L24-L35](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/relativeTime/index.js#L24-L35) [src/plugin/relativeTime/index.js#L49-L60](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/relativeTime/index.js#L49-L60) [src/plugin/calendar/index.js#L13-L30](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/calendar/index.js#L13-L30)
- customParseFormat's expressions table maps tokens to regex/parser pairs, while formattingTokens determines token recognition; new parsing tokens must fit both stages. — [src/plugin/customParseFormat/index.js#L3-L12](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/customParseFormat/index.js#L3-L12) [src/plugin/customParseFormat/index.js#L62-L79](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/customParseFormat/index.js#L62-L79) [src/plugin/customParseFormat/index.js#L146-L159](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/src/plugin/customParseFormat/index.js#L146-L159)
- Type declarations support module augmentation of Dayjs and factory APIs, and ConfigType derives from the augmentable ConfigTypeMap; timezone and duration declarations demonstrate overloaded plugin surfaces. — [types/index.d.ts#L5-L20](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/types/index.d.ts#L5-L20) [types/plugin/timezone.d.ts#L6-L19](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/types/plugin/timezone.d.ts#L6-L19) [types/plugin/duration.d.ts#L77-L87](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/types/plugin/duration.d.ts#L77-L87)
- Build discovery expects locale files and src/plugin/<name>/index modules, generates matching distribution names, and copies declarations; locale metadata extraction requires the identifying '// Name [code]' comment. — [build/index.js#L14-L33](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/build/index.js#L14-L33) [build/index.js#L40-L68](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/build/index.js#L40-L68) [test/plugin/declarations.test.js#L7-L12](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/test/plugin/declarations.test.js#L7-L12) [test/locale/keys.test.js#L37-L42](https://github.com/iamkun/dayjs/blob/436bde0bcded312781cbe45dc2b0ef079a36d8e3/test/locale/keys.test.js#L37-L42)

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)
