esday
v0.6.3
Published
A simple date library fully written in TypeScript
Readme
EsDay
Repository changing ownership
On the 6th of January 2026 this repository changed the ownership to one of it's maintainers, BePo65 to reduce the workload on g-mero.
EsDay is a JavaScript library inspired by Day.js, esday has a largely similar API to Day.js (v1.11.13), but it is written in TypeScript and fully supports es modules. Being compatible to Day.js, EsDay is also a good replacement for Moment.js.
import { esday } from 'esday'
import { isTodayPlugin } from 'esday/plugins/isToday'
esday.extend(isTodayPlugin)
esday('2024-12-10').set('year', 2025).add(1, 'month').isToday()For detailed information see the full documentation.
Concepts
- Modern API: Provides the same API as Day.js, with some features moved to plugins for a simpler core.
- Immutable: esday is immutable, which means that all operations will return a new instance of esday.
Differences to Day.js
- Locale is a Plugin: no default locale!
- default value for 'Start of Week' is 1 (as in ISO 8601): 'Start of Week' is 1 ('Monday').
- default value for 'Start of Year' is 4 (as in ISO 8601): 'Start of Year' is 4.
- clamping month on set: when changing the month and the new month does not have enough days to keep the current day of month, esday behaves like moment.js and clamps to the end of the target month
- Invalid Date: conforms to Moment.js and uses
Invalid dateinstead ofInvalid Date. - plugin AdvancedParse got replaced by CustomParseFormat.
- plugin ArraySupport: functionality is part of esday core.
- plugin IsoWeeksInYear: functionality is part of plugin IsoWeek.
- plugin PreParsePostFormat: functionality is part of esday core.
- plugin UpdateLocale: functionality is part of plugin Locale.
- plugin weekOfYear: functionality is part of plugin Week.
- plugin WeekYear: functionality is part of plugin Week.
- plugin Weekday: functionality is part of plugin Week.
Differences to Moment.js
Esday uses [email protected] as api reference.
- toString: conforms to Day.js and uses Date.toUTCString() (returning the date in RFC 7231 format 'ddd, DD MMM YYYY HH:mm:ss [GMT]') while moment uses the format 'ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'.
- toISOString: conforms to Day.js and returns 'Invalid date' when called on an invalid date. In that case moment returns null (see moment pr#3710).
Contribute
In the folder dev there is a template for creating new plugins and a template for new locale definitions.
License
This project is licensed under the MIT License.
This project also partially contains code derived or copied from the following projects:
