Skip to content
CAI
Software that uses CAICheck a score

iamkun/dayjs

49.9

Weak · 25 September 2026

8.7k

lines of production code

JavaScript

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a lightweight, modular date manipulation library designed as a modern alternative to Moment.js. It provides core date parsing, formatting, and arithmetic capabilities, extended through a plugin architecture that supports features like timezones, durations, and internationalization. The codebase includes comprehensive TypeScript definitions and extensive test coverage to ensure compatibility and reliability across various environments.

How it got here

2018 — Core refactoring and plugin architecture

16 changes.

The project underwent a significant modernization of its build infrastructure and core library structure, introducing a new locale system and modular plugin architecture. This period focused on expanding internationalization support with numerous new locale files and developing key plugins for advanced formatting, date comparisons, and calendar systems.

2019 — Plugin ecosystem and TypeScript support

17 changes.

This period focused on expanding the library's functionality through a comprehensive suite of new plugins, including support for quarters, UTC, ISO weeks, and locale data. Concurrently, the project established official TypeScript type definitions for both the core library and its plugins to improve developer experience. The architecture was also refined by extracting certain methods into separate plugins to maintain a modular design.

2020–2025 — extensive plugin ecosystem expansion

13 changes.

This period focused on significantly broadening the library's capabilities through the introduction of numerous specialized plugins, including support for ISO weeks, durations, timezones, and various input formats like objects and arrays. It also enhanced developer experience with a new helper for runtime warnings and improved locale management via nested merging. The work culminated in robust handling of edge cases such as BigInt values, negative years, and plugin interaction order.

Features

Add Buddhist Era (BE) year formatting support

Introduces a new plugin that enables formatting dates using the Buddhist Era calendar. When using the 'BBBB' or 'BB' format tokens, the year is automatically adjusted by adding 543 to the current year, supporting both 4-digit and 2-digit year representations.

src/plugin/buddhistEra · high confidence

Add DayOfYear plugin for date arithmetic

Introduces the new DayOfYear plugin, which adds a \dayOfYear\ method to the date object. This method calculates the day of the year (1-365/366) for the current date or, if an input is provided, returns a new date shifted by the difference between the input's day-of-year and the current date's day-of-year.

src/plugin/dayOfYear · high confidence

Add Experimental Timezone Plugin

Introduces a new timezone plugin that enables time-zone-aware date operations. Users can now convert dates to specific time zones using the \.tz()\ method, retrieve offset names (e.g., EST) via \.offsetName()\, and set a default time zone globally with \d.tz.setDefault()\. The plugin also includes a \d.tz.guess()\ utility to detect the user's local time zone and handles edge cases like DST transitions and invalid inputs.

src/plugin/timezone · high confidence

Add ISO Week plugin for date manipulation

Introduces a new plugin that adds ISO 8601 week-numbering support to the date library. Users can now access the ISO week year, current ISO week number, and ISO weekday via new prototype methods, and can use 'isoweek' as a unit for the startOf method to align dates to the beginning or end of an ISO week.

src/plugin/isoWeek · high confidence

Add TypeScript type definitions for dayjs locales

This change introduces TypeScript declaration files for dayjs locale modules. It defines an \ILocale\ interface in \types/locale/types.d.ts\ that specifies the structure of locale data (including names, weekdays, months, formats, and relative time strings) and a module declaration in \types/locale/index.d.ts\ that ensures imports from \dayjs/locale/\*\ are correctly typed as \locale.Locale\. This provides type safety for users working with dayjs locales in TypeScript projects.

types/locale · high confidence

Add UTC plugin for timezone-aware date handling

Introduces a new UTC plugin that enables Day.js instances to operate in UTC mode. This adds the \dayjs.utc()\ factory method and \.utc()\/\.local()\ instance methods for switching timezones, along with \.utcOffset()\ for setting or retrieving offsets. The plugin ensures correct parsing, formatting (defaulting to ISO 8601 with 'Z' suffix in UTC), and comparison logic by handling UTC-specific initialization and offset adjustments, resolving previous inconsistencies in UTC-related operations.

src/plugin/utc · high confidence

Add arraySupport plugin for parsing date arrays

A new arraySupport plugin has been added to enable parsing date configurations where the date is provided as an array. This allows users to initialize dayjs instances using array-based date inputs, with support for both UTC and local time zones.

src/plugin/arraySupport · high confidence

Add isBetween plugin with configurable inclusivity

The new isBetween plugin allows users to check if a date falls between two other dates, supporting configurable inclusivity for the start and end boundaries via a fourth argument (defaulting to exclusive on both ends).

src/plugin/isBetween · high confidence

Add isLeapYear plugin to extend date object prototype

A new plugin located at src/plugin/isLeapYear/index.js has been introduced, which extends the date object prototype with an isLeapYear method. This allows users to directly check if a year is a leap year on date instances using the internal $y property.

src/plugin/isLeapYear · high confidence

Add isMoment plugin for Moment.js compatibility

The new isMoment plugin adds an isMoment method to the Day.js API, allowing users to check if an object is a Moment.js instance. This method delegates to the existing isDayjs function, providing a compatibility layer for codebases that rely on Moment.js type checking.

src/plugin/isMoment · high confidence

Add isToday, isTomorrow, and isYesterday date comparison plugins

New plugins have been added to allow users to check if a date instance corresponds to today, tomorrow, or yesterday. These methods compare the formatted date string (YYYY-MM-DD) against the current date or the date shifted by one day forward or backward, providing a convenient way to perform relative date checks.

src/plugin/isToday, src/plugin/isTomorrow, src/plugin/isYesterday · high confidence

Add isoWeeksInYear plugin

A new plugin is introduced that adds an isoWeeksInYear method to the date prototype, allowing users to determine whether a given year contains 52 or 53 ISO weeks based on leap year status and the day of the week for the year's end.

src/plugin/isoWeeksInYear · high confidence

Add locale-aware weekday plugin

Introduces a new plugin that provides a \weekday\ method on date instances. This method returns the day of the week as an integer, adjusted for the current locale's week start day, and allows setting the date to a specific weekday by shifting days accordingly.

src/plugin/weekday · high confidence

Add localeData plugin for comprehensive locale information access

Introduces the new \localeData\ plugin, which exposes detailed locale metadata and formatting utilities. Users can now access global locale data via \dayjs.localeData()\ (providing months, weekdays, first day of week, long date formats, meridiem, and ordinal functions) and instance-specific data via \instance.localeData()\. The plugin also adds convenience methods like \dayjs.months()\, \dayjs.weekdays()\, and their short/min variants to retrieve localized calendar names directly.

src/plugin/localeData · high confidence

Add minMax plugin for date range selection

Introduces the minMax plugin, which adds \min\ and \max\ methods to the date instance. These methods allow users to programmatically determine the earliest or latest date from a provided list of arguments, handling edge cases such as empty arrays, null values, and single-argument inputs.

src/plugin/minMax · high confidence

Add negative year parsing support to dayjs

Introduces a new plugin that enables dayjs to parse dates with negative years (e.g., '-100'). The plugin intercepts the date parsing logic to detect strings starting with a minus sign, strips the prefix, and adjusts the resulting date by subtracting twice the year value to correctly represent the negative timeline. It also supports UTC parsing when the UTC flag is enabled in the configuration.

src/plugin/negativeYear · high confidence

Add objectSupport plugin for object-based date manipulation

Introduces the new objectSupport plugin, enabling dayjs to accept JavaScript objects for date parsing and manipulation. Users can now pass an object with keys like 'year', 'month', 'day', etc., to the constructor to create a date instance, where an empty object defaults to the current date. Additionally, the plugin allows passing objects to the set, add, and subtract methods to modify multiple date units in a single call, such as adding years and months simultaneously.

src/plugin/objectSupport · high confidence

Add plural getter/setter aliases for date units

The new PluralGetSet plugin adds plural aliases (e.g., 'milliseconds', 'seconds', 'months') to the date object prototype, allowing users to use plural forms for getters and setters that map directly to their singular counterparts.

src/plugin/pluralGetSet · high confidence

Add quarter-of-year support via new plugin

Introduces the new \quarterOfYear\ plugin, enabling users to query, add, and manipulate dates by quarter. This adds a \quarter()\ method to get or set the current quarter, extends the \add()\ method to support adding quarters (which internally adds 3 months), and extends \startOf()\ to support setting the date to the start or end of a quarter.

src/plugin/quarterOfYear · high confidence

Add support for BigInt values in date parsing and Unix timestamps

The new BigIntSupport plugin allows dayjs to correctly handle JavaScript BigInt values when parsing dates or creating instances from Unix timestamps. Previously, passing a BigInt to the date configuration or the unix() method would likely fail or behave unexpectedly; this plugin intercepts these inputs, converts the BigInt to a standard Number, and passes it to the existing parsing logic, ensuring compatibility with codebases that use BigInt for large numeric values.

src/plugin/bigIntSupport · high confidence

Add weekYear plugin to retrieve the ISO week-numbering year

The new weekYear plugin adds a weekYear() method to the date prototype, allowing users to retrieve the year associated with the ISO week-numbering system. This method correctly handles edge cases where the ISO week belongs to the adjacent year, such as the first week of January or the last week of December.

src/plugin/weekYear · high confidence

Added 79 new locale files for internationalization

The \src/locale\ directory now includes 79 new locale definition files (e.g., Afrikaans, Amharic, Arabic variants, Bengali, Bulgarian, Catalan, Czech, Danish, German variants, Greek, English variants, Esperanto, Spanish variants, etc.). These files provide translations for weekdays, months, relative time, and date formats, enabling users to display dates and times in their respective languages and regional settings.

src/locale · high confidence

Added isSameOrAfter and isSameOrBefore date comparison methods

The library now includes two new date comparison methods: \isSameOrAfter\ and \isSameOrBefore\. These allow users to check if a date is equal to or after/before another date in a single call, combining the existing \isSame\ logic with \isAfter\ or \isBefore\ respectively.

src/plugin/isSameOrAfter, src/plugin/isSameOrBefore · high confidence

AdvancedFormat plugin adds support for ISO week, week year, and ordinal tokens

The new AdvancedFormat plugin extends date formatting by supporting additional tokens for week-based calculations and ordinal numbers. Users can now format dates using 'gggg' and 'GGGG' for local and ISO week years, 'w', 'ww', 'W', and 'WW' for local and ISO week numbers, and 'wo' for the week number with an ordinal suffix (e.g., '1st'). The plugin also handles 'Q' for the quarter, 'Do' for the day of the month with an ordinal, 'k'/'kk' for 24-hour clock hours (1-24), 'X'/'x' for Unix timestamps, and 'z'/'zzz' for timezone offset names. This functionality is integrated into the core format method, wrapping existing behavior to provide these extended capabilities.

src/plugin/advancedFormat · high confidence

Calendar plugin adds relative date formatting

The calendar plugin now includes a \calendar\ method that formats dates using relative terms (e.g., "Yesterday at", "Today at", "Tomorrow at") based on a reference time. This allows users to display dates in a more human-readable, context-aware format rather than just static strings.

src/plugin/calendar · high confidence

DevHelper plugin adds runtime warnings for common day.js usage mistakes

A new devHelper plugin has been added to src/plugin/devHelper/index.js that intercepts core day.js methods (parse, locale, diff) to emit console warnings in non-production environments. Users will now see specific guidance when passing a 4-digit number as a year (which is treated as a Unix timestamp), when using custom parse formats without enabling the customParseFormat plugin, when setting a locale that hasn't been loaded, or when calling diff() with an invalid date.

src/plugin/devHelper · high confidence

Initial TypeScript type definitions for Day.js

This change introduces the \types/index.d.ts\ file, providing the first official TypeScript definitions for the Day.js library. It defines the core \dayjs\ function signatures, the \Dayjs\ class interface with methods for date manipulation (get/set year, month, day, etc.), and supporting types for configuration, units, and options. This enables TypeScript users to get proper type checking and IntelliSense support when using Day.js.

types · high confidence

Introduce Duration plugin for time interval handling

Adds the Duration plugin, enabling users to create, manipulate, and format time intervals (durations) alongside standard date objects. This new capability allows parsing ISO 8601 duration strings, performing arithmetic operations like adding or subtracting durations from dayjs instances, and converting durations to ISO strings or formatted text via the new \duration.format()\ method.

src/plugin/duration · high confidence

Introduce customParseFormat plugin for flexible date string parsing

The new customParseFormat plugin enables parsing date strings using custom format tokens (such as YYYY, MM, DD, HH, mm, ss, Z, and locale-aware formats like MMMM or Do). It supports two-digit year parsing, timezone offsets (including Zulu time), meridiem handling (AM/PM), and quarter/week-of-year formats, allowing users to parse a wider variety of date string representations than the core library previously supported.

src/plugin/customParseFormat · high confidence

Introduce preParsePostFormat plugin and update relativeTime plugin logic

This change introduces the new preParsePostFormat plugin, which allows locales to define custom preparse and postformat functions to transform date strings before parsing and formatted output after generation. It also updates the relativeTime plugin to support function-based configurations for future and past strings, enabling more dynamic relative time formatting, and fixes a rounding bug in the calculation logic.

src/plugin/relativeTime · high confidence

New updateLocale plugin with nested object merging

Added the updateLocale plugin, which introduces a dayjs.updateLocale method to modify existing locale configurations. Unlike a simple replacement, this implementation merges nested object properties (such as relative time formats) rather than overwriting them entirely, allowing users to update specific locale attributes without losing other existing settings.

src/plugin/updateLocale · high confidence

TypeScript definitions added for all dayjs plugins

The \types/plugin\ directory now contains \.d.ts\ files for every dayjs plugin, providing full TypeScript support for the library's modular architecture. This includes type definitions for core functionality plugins like \utc\, \timezone\, \duration\, and \localeData\, as well as utility plugins such as \minMax\, \isBetween\, \isToday\, \isTomorrow\, \isYesterday\, \isLeapYear\, \isSameOrAfter\, \isSameOrBefore\, \isMoment\, \toArray\, \toObject\, \customParseFormat\, \preParsePostFormat\, \localizedFormat\, \advancedFormat\, \buddhistEra\, \devHelper\, \negativeYear\, \objectSupport\, \pluralGetSet\, \quarterOfYear\, \relativeTime\, \updateLocale\, \weekOfYear\, \weekYear\, \weekday\, \arraySupport\, \badMutable\, \bigIntSupport\, and \isoWeek\/\isoWeeksInYear\. Users can now import and use these plugins with complete type safety, including correct method signatures, return types, and configuration options.

types/plugin · high confidence

Architecture

Extract weekOfYear functionality into a dedicated plugin

The week and weeks methods have been moved from the core library to a new weekOfYear plugin. This change decouples week-numbering logic from the main build, allowing users to include week calculation features only when needed and resolving issues related to locale handling and interactions with other plugins like BadMutable.

src/plugin/weekOfYear · high confidence

Behavioural changes

Core library refactored with new locale system and parsing logic

The core \src\ files have been significantly refactored to improve modularity and correctness. The \src/constant.js\ file now exports explicit constants for date formats (including \FORMAT\_DEFAULT\ and \INVALID\_DATE\_STRING\) and robust regular expressions for parsing (\REGEX\_PARSE\) and formatting (\REGEX\_FORMAT\). In \src/index.js\, the global state management has been updated to support a new locale system with fallbacks, and the date parsing logic has been rewritten to handle string inputs more strictly using the new regexes, while also introducing a \wrapper\ function to preserve instance context. The \src/utils.js\ module has been restructured to export a plain object of utility functions (such as \padStart\, \monthDiff\, and \prettyUnit\) rather than individual named exports, facilitating easier plugin integration and internal consistency.

src · high confidence

Filtering out low-numbered pull requests in GitHub success notifications

The @semantic-release/github plugin now excludes pull requests with numbers below 2000 from the success notification logic. This change modifies the filtering step that determines which associated pull requests are processed, effectively ignoring older or lower-numbered PRs during the success phase of the release workflow.

patches · medium confidence

Introduction of badMutable plugin for date manipulation

A new plugin named 'badMutable' has been added to the codebase. This plugin modifies the prototype of the date object to introduce mutable behavior, specifically by overriding methods such as startOf, add, locale, daysInMonth, isSame, isBefore, and isAfter to allow in-place modification or cloning before comparison. It also adds a $g utility method for getting and setting values. This change affects how date instances behave when these specific methods are called, potentially altering existing date handling logic.

src/plugin/badMutable · high confidence

Repository structure and build tooling modernization

The project has reorganized its configuration and build infrastructure to support modern development workflows. The legacy Travis CI setup (.travis.yml) and the old Rollup-based build script (rollup.config.js) have been removed, replaced by a new Babel configuration (babel.config.js) and a Semantic Release configuration (.releaserc) for automated versioning and changelog generation. Code formatting is now standardized via Prettier (prettier.config.js), and linting rules have been expanded in the renamed .eslintrc.json. Additionally, the repository now includes a .editorconfig for consistent editor settings, updated .gitignore and .npmignore files to exclude new build artifacts (like /build, /esm, and locale.json), and the main documentation has been consolidated into a new README.md with updated sponsor and contributor sections.

(repo-wide) · high confidence

Restructured build system with dedicated ESM post-processing and UMD configuration

The build process has been reorganized into a modular structure under the \build/\ directory, introducing \index.js\ for sequential UMD compilation of locales and plugins, \rollup.config.js\ to define UMD output with externalized 'dayjs' dependencies, and a new \esm.js\ script. This ESM script specifically handles post-processing for the ES Module build by copying TypeScript definitions, updating import paths from 'dayjs' to 'dayjs/esm' in locale and plugin type files, and generating a \locale.json\ manifest. This change ensures that both UMD and ESM outputs have correct pathing and type definitions, addressing previous issues with broken UTC plugins and missing type definitions in the ESM build.

build · high confidence

toObject and toArray methods moved to separate plugins

The \toObject\ and \toArray\ methods, which previously existed in the core library, have been extracted into their own distinct plugin modules (\src/plugin/toObject\ and \src/plugin/toArray\). Users will now need to explicitly include these plugins to access the functionality that converts date instances into an array of components or an object with named properties.

src/plugin/toArray, src/plugin/toObject · high confidence

Fixes

LocalizedFormat plugin now supports lowercase format tokens

The localizedFormat plugin has been updated to recognize and correctly process lowercase localized format tokens (l, ll, lll, llll) in addition to the existing uppercase variants. This ensures that date strings formatted with these lowercase tokens are properly resolved using locale-specific formats, fixing previous issues where such formats were not handled correctly.

src/plugin/localizedFormat · high confidence

Test coverage

Added dayjs mock for tests; Added test coverage for multiple Day.js plugins; Added tests for objectSupport and Duration plugin interaction order; Added unit tests for locale localization coverage; Expanded test coverage for core date manipulation and formatting APIs.

Dependencies

Dependency and build configuration overhaul

The project's dependency tree and build configuration have been significantly updated. Rollup has been upgraded from version 0.57 to 2.45, replacing the Uglify plugin with Terser for minification. Development tooling now includes TypeScript for type definitions, Prettier for code formatting, and size-limit for bundle size monitoring. The main entry point has shifted to 'dayjs.min.js', and the test suite now utilizes cross-env for timezone isolation and Karma with Sauce Labs for browser testing, while the moment dependency is pinned to version 2.29.2.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 37 → 50 (+13.3)
  • Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 44 → 42 (-1.3)
  • Architecture 100 (new)
  • Maturity 59 → 56 (-2.8)
  • Readiness 26 → 55 (+28.4)
  • Security 46 → 51 (+4.8)

Resolved (82)

  • (anonymous) (cyclomatic 20) (src/plugin/advancedFormat/index.js)
  • Boundary-crossing change coupling: index.js ↔ duration.d.ts (src/plugin/duration/index.js)
  • Boundary-crossing change coupling: index.js ↔ timezone.d.ts (src/plugin/timezone/index.js)
  • Boundary-crossing change coupling: index.js ↔ utc.d.ts (src/plugin/utc/index.js)
  • Change coupling: index.js ↔ en.js (src/index.js)
  • Change coupling: index.js ↔ utc.d.ts (src/index.js)
  • Change coupling: index.js ↔ utils.js (src/index.js)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • …and 62 more

New (163)

  • (anonymous) (cognitive 19) (src/plugin/timezone/index.js)
  • (anonymous) (cognitive 20) (src/plugin/devHelper/index.js)
  • (anonymous) (cognitive 25) (src/plugin/utc/index.js)
  • (anonymous) (cyclomatic 16) (src/plugin/customParseFormat/index.js)
  • (anonymous) (cyclomatic 18) (src/plugin/timezone/index.js)
  • (anonymous) (cyclomatic 22) (src/plugin/advancedFormat/index.js)
  • (anonymous) (cyclomatic 22) (src/plugin/utc/index.js)
  • (anonymous)::fromToBase (cognitive 26) (src/plugin/relativeTime/index.js)
  • (anonymous)::fromToBase (cyclomatic 16) (src/plugin/relativeTime/index.js)
  • (anonymous)::parse (cognitive 23) (src/plugin/customParseFormat/index.js)
  • (anonymous)::parseDate (cognitive 21) (src/plugin/objectSupport/index.js)
  • (anonymous)::parseDate (cyclomatic 16) (src/plugin/objectSupport/index.js)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • Critical CVE: [GHSA redacted] (package-lock.json)
  • …and 143 more

Changes since last survey

  • 11 commits — 9 feature/other, 2 fixes

By area

  • (root) — 9 commits
  • (repo) — 1 commit
  • src/plugin — 1 commit

Notable commits

  • fix: fix(plugin): timezone compute instance .tz() offset without host DST (#3174)
  • fix: fix(plugin): timezone plugin prevent RangeError for invalid Day.js values (#3180)
  • change: D2M (#3177)
  • change: chore(release): 1.11.22 [skip ci]
  • change: chore: update doc
  • change: chore: update doc
  • change: chore: update doc
  • change: chore: update doc
  • change: chore: update doc
  • change: chore: update doc
  • change: docs: use npm test in contributing guide (#3179)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

iamkun/dayjs was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 25 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 436bde0bcded312781cbe45dc2b0ef079a36d8e3 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-dd72cc24c749.