mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 17:46:44 +02:00
refactor(deps): replace moment
with dayjs
Replace Mermaid's dependency on `moment` with `dayjs`. [Moment is now in maintenance mode][1], and they don't recommend using it. [Dayjs][2] has almost exactly the same API as moment, and is still curently being maintained. Unlike moment, dayjs objects are immutable, which makes our life much easier, but we need to do `a = a.add(1, "day")` instead of just `a.add(1, "day")`. We can't use `dayjs.duration`, because unlike `moment.duration`, [dayjs durations always degrade to ms][3]. This causes issues with daylight savings, since it assumes that each day is 24 hours, when some days have 23/25 hours with daylight savings. (it also assumes that each month is 30 days). However, `dayjs.add(1, "d");` correctly adds 1 days, even when that day is only 23 hours long, so we can use that instead. [1]: https://momentjs.com/docs/#/-project-status/ [2]: https://day.js.org/ [3]: https://day.js.org/docs/en/durations/durations
This commit is contained in:
@@ -184,7 +184,7 @@ The following formatting options are supported:
|
||||
| `YY` | 14 | 2 digit year |
|
||||
| `Q` | 1..4 | Quarter of year. Sets month to first month in quarter. |
|
||||
| `M MM` | 1..12 | Month number |
|
||||
| `MMM MMMM` | January..Dec | Month name in locale set by `moment.locale()` |
|
||||
| `MMM MMMM` | January..Dec | Month name in locale set by `dayjs.locale()` |
|
||||
| `D DD` | 1..31 | Day of month |
|
||||
| `Do` | 1st..31st | Day of month with ordinal |
|
||||
| `DDD DDDD` | 1..365 | Day of year |
|
||||
@@ -200,7 +200,7 @@ The following formatting options are supported:
|
||||
| `SSS` | 0..999 | Thousandths of a second |
|
||||
| `Z ZZ` | +12:00 | Offset from UTC as +-HH:mm, +-HHmm, or Z |
|
||||
|
||||
More info in: <https://momentjs.com/docs/#/parsing/string-format/>
|
||||
More info in: <https://day.js.org/docs/en/parse/string-format/>
|
||||
|
||||
### Output date format on the axis
|
||||
|
||||
|
Reference in New Issue
Block a user