Read OSS

iamkun/dayjs

3 articles

Prerequisites

01

Day.js Architecture: How 2KB Replaces Moment.js

A high-level tour of how Day.js achieves Moment.js API compatibility in ~467 lines through a micro-core, opt-in plugins, and immutability by default.

02

The Plugin Architecture: Monkey-Patching as a Feature

Deep dive into Day.js's plugin system—how extend() installs plugins, how prototype wrapping creates middleware chains, and how 37 plugins keep the core tiny.

03

Date Parsing and the UTC/Timezone Stack

Explores the three-layer time handling architecture: core parseDate(), the UTC plugin's $u flag and $offset mechanism, and the timezone plugin's Intl.DateTimeFormat-based DST resolution.