Repository: iamkun/dayjs Branch: dev Commit: cfd7e721b04d Files: 378 Total size: 755.2 KB Directory structure: gitextract_xim833qs/ ├── .editorconfig ├── .eslintrc.json ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ └── --bug-report.md │ └── workflows/ │ ├── check.yml │ ├── lint-test.yml │ └── release.yml ├── .gitignore ├── .npmignore ├── .releaserc ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── babel.config.js ├── build/ │ ├── esm.js │ ├── index.js │ └── rollup.config.js ├── docs/ │ ├── demo/ │ │ └── index.js │ ├── en/ │ │ ├── API-reference.md │ │ ├── I18n.md │ │ ├── Installation.md │ │ └── Plugin.md │ ├── es-es/ │ │ ├── API-reference.md │ │ ├── I18n.md │ │ ├── Installation.md │ │ ├── Plugin.md │ │ └── README-es-es.md │ ├── fr/ │ │ └── README-fr.md │ ├── he/ │ │ └── README-he.md │ ├── ja/ │ │ ├── API-reference.md │ │ ├── I18n.md │ │ ├── Installation.md │ │ ├── Plugin.md │ │ └── README-ja.md │ ├── ko/ │ │ ├── API-reference.md │ │ ├── I18n.md │ │ ├── Installation.md │ │ ├── Plugin.md │ │ └── README-ko.md │ ├── pt-br/ │ │ ├── API-reference.md │ │ ├── I18n.md │ │ ├── Installation.md │ │ ├── Plugin.md │ │ └── README-pt-br.md │ ├── ru/ │ │ ├── LICENSE-ru │ │ └── README-ru.md │ ├── si/ │ │ └── README-si.md │ ├── sw/ │ │ └── README-sw.md │ ├── tr/ │ │ └── README-tr.md │ └── zh-cn/ │ ├── API-reference.md │ ├── I18n.md │ ├── Installation.md │ ├── Plugin.md │ └── README.zh-CN.md ├── karma.sauce.conf.js ├── package.json ├── patches/ │ └── @semantic-release+github+11.0.4.patch ├── prettier.config.js ├── src/ │ ├── constant.js │ ├── index.js │ ├── locale/ │ │ ├── af.js │ │ ├── am.js │ │ ├── ar-dz.js │ │ ├── ar-iq.js │ │ ├── ar-kw.js │ │ ├── ar-ly.js │ │ ├── ar-ma.js │ │ ├── ar-sa.js │ │ ├── ar-tn.js │ │ ├── ar.js │ │ ├── az.js │ │ ├── be.js │ │ ├── bg.js │ │ ├── bi.js │ │ ├── bm.js │ │ ├── bn-bd.js │ │ ├── bn.js │ │ ├── bo.js │ │ ├── br.js │ │ ├── bs.js │ │ ├── ca.js │ │ ├── cs.js │ │ ├── cv.js │ │ ├── cy.js │ │ ├── da.js │ │ ├── de-at.js │ │ ├── de-ch.js │ │ ├── de.js │ │ ├── dv.js │ │ ├── el.js │ │ ├── en-au.js │ │ ├── en-ca.js │ │ ├── en-gb.js │ │ ├── en-ie.js │ │ ├── en-il.js │ │ ├── en-in.js │ │ ├── en-nz.js │ │ ├── en-sg.js │ │ ├── en-tt.js │ │ ├── en.js │ │ ├── eo.js │ │ ├── es-do.js │ │ ├── es-mx.js │ │ ├── es-pr.js │ │ ├── es-us.js │ │ ├── es.js │ │ ├── et.js │ │ ├── eu.js │ │ ├── fa.js │ │ ├── fi.js │ │ ├── fo.js │ │ ├── fr-ca.js │ │ ├── fr-ch.js │ │ ├── fr.js │ │ ├── fy.js │ │ ├── ga.js │ │ ├── gd.js │ │ ├── gl.js │ │ ├── gom-latn.js │ │ ├── gu.js │ │ ├── he.js │ │ ├── hi.js │ │ ├── hr.js │ │ ├── ht.js │ │ ├── hu.js │ │ ├── hy-am.js │ │ ├── id.js │ │ ├── is.js │ │ ├── it-ch.js │ │ ├── it.js │ │ ├── ja.js │ │ ├── jv.js │ │ ├── ka.js │ │ ├── kk.js │ │ ├── km.js │ │ ├── kn.js │ │ ├── ko.js │ │ ├── ku.js │ │ ├── ky.js │ │ ├── lb.js │ │ ├── lo.js │ │ ├── lt.js │ │ ├── lv.js │ │ ├── me.js │ │ ├── mi.js │ │ ├── mk.js │ │ ├── ml.js │ │ ├── mn.js │ │ ├── mr.js │ │ ├── ms-my.js │ │ ├── ms.js │ │ ├── mt.js │ │ ├── my.js │ │ ├── nb.js │ │ ├── ne.js │ │ ├── nl-be.js │ │ ├── nl.js │ │ ├── nn.js │ │ ├── oc-lnc.js │ │ ├── pa-in.js │ │ ├── pl.js │ │ ├── pt-br.js │ │ ├── pt.js │ │ ├── rn.js │ │ ├── ro.js │ │ ├── ru.js │ │ ├── rw.js │ │ ├── sd.js │ │ ├── se.js │ │ ├── si.js │ │ ├── sk.js │ │ ├── sl.js │ │ ├── sq.js │ │ ├── sr-cyrl.js │ │ ├── sr.js │ │ ├── ss.js │ │ ├── sv-fi.js │ │ ├── sv.js │ │ ├── sw.js │ │ ├── ta.js │ │ ├── te.js │ │ ├── tet.js │ │ ├── tg.js │ │ ├── th.js │ │ ├── tk.js │ │ ├── tl-ph.js │ │ ├── tlh.js │ │ ├── tr.js │ │ ├── tzl.js │ │ ├── tzm-latn.js │ │ ├── tzm.js │ │ ├── ug-cn.js │ │ ├── uk.js │ │ ├── ur.js │ │ ├── uz-latn.js │ │ ├── uz.js │ │ ├── vi.js │ │ ├── x-pseudo.js │ │ ├── yo.js │ │ ├── zh-cn.js │ │ ├── zh-hk.js │ │ ├── zh-tw.js │ │ └── zh.js │ ├── plugin/ │ │ ├── advancedFormat/ │ │ │ └── index.js │ │ ├── arraySupport/ │ │ │ └── index.js │ │ ├── badMutable/ │ │ │ └── index.js │ │ ├── bigIntSupport/ │ │ │ └── index.js │ │ ├── buddhistEra/ │ │ │ └── index.js │ │ ├── calendar/ │ │ │ └── index.js │ │ ├── customParseFormat/ │ │ │ └── index.js │ │ ├── dayOfYear/ │ │ │ └── index.js │ │ ├── devHelper/ │ │ │ └── index.js │ │ ├── duration/ │ │ │ └── index.js │ │ ├── isBetween/ │ │ │ └── index.js │ │ ├── isLeapYear/ │ │ │ └── index.js │ │ ├── isMoment/ │ │ │ └── index.js │ │ ├── isSameOrAfter/ │ │ │ └── index.js │ │ ├── isSameOrBefore/ │ │ │ └── index.js │ │ ├── isToday/ │ │ │ └── index.js │ │ ├── isTomorrow/ │ │ │ └── index.js │ │ ├── isYesterday/ │ │ │ └── index.js │ │ ├── isoWeek/ │ │ │ └── index.js │ │ ├── isoWeeksInYear/ │ │ │ └── index.js │ │ ├── localeData/ │ │ │ └── index.js │ │ ├── localizedFormat/ │ │ │ ├── index.js │ │ │ └── utils.js │ │ ├── minMax/ │ │ │ └── index.js │ │ ├── negativeYear/ │ │ │ └── index.js │ │ ├── objectSupport/ │ │ │ └── index.js │ │ ├── pluralGetSet/ │ │ │ └── index.js │ │ ├── preParsePostFormat/ │ │ │ └── index.js │ │ ├── quarterOfYear/ │ │ │ └── index.js │ │ ├── relativeTime/ │ │ │ └── index.js │ │ ├── timezone/ │ │ │ └── index.js │ │ ├── toArray/ │ │ │ └── index.js │ │ ├── toObject/ │ │ │ └── index.js │ │ ├── updateLocale/ │ │ │ └── index.js │ │ ├── utc/ │ │ │ └── index.js │ │ ├── weekOfYear/ │ │ │ └── index.js │ │ ├── weekYear/ │ │ │ └── index.js │ │ └── weekday/ │ │ └── index.js │ └── utils.js ├── test/ │ ├── __mocks__/ │ │ └── dayjs.js │ ├── browser.spec.js │ ├── comparison.test.js │ ├── constructor.test.js │ ├── display.test.js │ ├── get-set.test.js │ ├── issues/ │ │ ├── issue2027.correct-order.test.js │ │ └── issue2027.swapped-order.test.js │ ├── locale/ │ │ ├── ar-dz.test.js │ │ ├── ar-iq.test.js │ │ ├── ar-kw.test.js │ │ ├── ar-ly.test.js │ │ ├── ar-ma.test.js │ │ ├── ar-sa.test.js │ │ ├── ar-tn.test.js │ │ ├── ar.test.js │ │ ├── be.test.js │ │ ├── bg.test.js │ │ ├── bn-bd.test.js │ │ ├── bn.test.js │ │ ├── br.test.js │ │ ├── cs.test.js │ │ ├── de.test.js │ │ ├── en.test.js │ │ ├── et.test.js │ │ ├── fi.test.js │ │ ├── he.test.js │ │ ├── hr.test.js │ │ ├── hu.test.js │ │ ├── is.test.js │ │ ├── it-ch.test.js │ │ ├── it.test.js │ │ ├── ja.test.js │ │ ├── keys.test.js │ │ ├── ku.test.js │ │ ├── lt.test.js │ │ ├── pl.test.js │ │ ├── ru.test.js │ │ ├── sk.test.js │ │ ├── sl.test.js │ │ ├── sr-cyrl.test.js │ │ ├── sr.test.js │ │ ├── sv-fi.test.js │ │ ├── sv.test.js │ │ ├── uk.test.js │ │ ├── zh-cn.test.js │ │ ├── zh-hk.test.js │ │ ├── zh-tw.test.js │ │ └── zh.test.js │ ├── locale.test.js │ ├── manipulate.test.js │ ├── parse.test.js │ ├── plugin/ │ │ ├── advancedFormat.test.js │ │ ├── arraySupport.test.js │ │ ├── badMutable.test.js │ │ ├── bigIntSupport.test.js │ │ ├── buddhistEra.test.js │ │ ├── calendar.test.js │ │ ├── customParseFormat.test.js │ │ ├── dayOfYear.test.js │ │ ├── declarations.test.js │ │ ├── devHelper.test.js │ │ ├── duration.test.js │ │ ├── isBetween.test.js │ │ ├── isLeapYear.test.js │ │ ├── isMoment.test.js │ │ ├── isSameOrAfter.test.js │ │ ├── isSameOrBefore.test.js │ │ ├── isToday.test.js │ │ ├── isTomorrow.test.js │ │ ├── isYesterday.test.js │ │ ├── isoWeek.test.js │ │ ├── isoWeeksInYear.test.js │ │ ├── localeData.test.js │ │ ├── localizedFormat.test.js │ │ ├── minMax.test.js │ │ ├── negativeYear.test.js │ │ ├── objectSupport.test.js │ │ ├── pluralGetSet.test.js │ │ ├── preParsePostFormat.test.js │ │ ├── quarterOfYear.test.js │ │ ├── relativeTime.test.js │ │ ├── timezone.test.js │ │ ├── toArray.test.js │ │ ├── toObject.test.js │ │ ├── updateLocale.test.js │ │ ├── utc-utcOffset.test.js │ │ ├── utc.test.js │ │ ├── weekOfYear.test.js │ │ ├── weekYear.test.js │ │ └── weekday.test.js │ ├── plugin.test.js │ ├── query.test.js │ ├── timezone.test.js │ └── utils.test.js └── types/ ├── index.d.ts ├── locale/ │ ├── index.d.ts │ └── types.d.ts └── plugin/ ├── advancedFormat.d.ts ├── arraySupport.d.ts ├── badMutable.d.ts ├── bigIntSupport.d.ts ├── buddhistEra.d.ts ├── calendar.d.ts ├── customParseFormat.d.ts ├── dayOfYear.d.ts ├── devHelper.d.ts ├── duration.d.ts ├── isBetween.d.ts ├── isLeapYear.d.ts ├── isMoment.d.ts ├── isSameOrAfter.d.ts ├── isSameOrBefore.d.ts ├── isToday.d.ts ├── isTomorrow.d.ts ├── isYesterday.d.ts ├── isoWeek.d.ts ├── isoWeeksInYear.d.ts ├── localeData.d.ts ├── localizedFormat.d.ts ├── minMax.d.ts ├── negativeYear.d.ts ├── objectSupport.d.ts ├── pluralGetSet.d.ts ├── preParsePostFormat.d.ts ├── quarterOfYear.d.ts ├── relativeTime.d.ts ├── timezone.d.ts ├── toArray.d.ts ├── toObject.d.ts ├── updateLocale.d.ts ├── utc.d.ts ├── weekOfYear.d.ts ├── weekYear.d.ts └── weekday.d.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_size = 2 ================================================ FILE: .eslintrc.json ================================================ { "extends": "airbnb-base", "plugins": [ "jest" ], "env": { "jest/globals": true }, "globals": { "window": true, "dayjs": true }, "rules": { "semi": [ 2, "never" ], "comma-dangle": [ "error", "never" ], "no-param-reassign": [ 0 ], "func-names": [ 0 ], "import/no-extraneous-dependencies": [ 0 ], "import/no-unresolved": [ 2, { "ignore": [ "dayjs" ] } ], "import/extensions": [ 2, "never" ] } } ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [iamkun] patreon: # Replace with a single Patreon username open_collective: dayjs ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/ISSUE_TEMPLATE/--bug-report.md ================================================ --- name: "\U0001F4A9Bug report" about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **Expected behavior** A clear and concise description of what you expected to happen. **Information** - Day.js Version [e.g. v1.0.0] - OS: [e.g. iOS] - Browser [e.g. chrome 62] - Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)] ================================================ FILE: .github/workflows/check.yml ================================================ name: Lint & Unit Test on: push: branches: [dev] pull_request: branches: [dev] jobs: check: uses: ./.github/workflows/lint-test.yml secrets: inherit ================================================ FILE: .github/workflows/lint-test.yml ================================================ on: workflow_call: secrets: CODECOV_TOKEN: required: false jobs: lint-and-test: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 with: node-version: 'lts/*' cache: 'npm' - name: Install dependencies run: npm install - name: Run Lint run: npm run lint - name: Run tests run: npm test - name: Upload coverage to Codecov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} if: env.CODECOV_TOKEN != null uses: codecov/codecov-action@v4 with: token: ${{ env.CODECOV_TOKEN }} ================================================ FILE: .github/workflows/release.yml ================================================ name: Release on: push: branches: [master] jobs: lint-and-test: uses: ./.github/workflows/lint-test.yml secrets: inherit release: needs: lint-and-test runs-on: ubuntu-latest permissions: contents: write issues: write pull-requests: write id-token: write steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: 'lts/*' - name: Install dependencies run: npm clean-install - name: Build env: NODE_OPTIONS: --openssl-legacy-provider run: npm run build && npm run babel - name: Verify provenance run: npm audit signatures - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npm install @semantic-release/changelog @semantic-release/git semantic-release --no-save npx patch-package npx semantic-release ================================================ FILE: .gitignore ================================================ # OSX .DS_Store # IDE .idea .vscode # npm node_modules yarn.lock # jest coverage # build /locale /plugin /dayjs.min.js /esm /index.d.ts locale.json #dev demo.js ================================================ FILE: .npmignore ================================================ # OSX .DS_Store # IDE .idea # npm node_modules yarn.lock package-lock.json # jest coverage # dev src test types build babel.config.js prettier.config.js .eslintrc.json patches #doc CONTRIBUTING.md docs #other .travis.yml karma.sauce.conf.js .github .releaserc ================================================ FILE: .releaserc ================================================ { "branches": ["master"], "prepare": [ { "path": "@semantic-release/changelog" }, [ "@semantic-release/git", { "assets": [ "CHANGELOG.md" ] } ] ] } ================================================ FILE: CHANGELOG.md ================================================ ## [1.11.20](https://github.com/iamkun/dayjs/compare/v1.11.19...v1.11.20) (2026-03-12) ### Bug Fixes * Update locale km.js to support meridiem ([#3017](https://github.com/iamkun/dayjs/issues/3017)) ([9d2b6a1](https://github.com/iamkun/dayjs/commit/9d2b6a1ec744ad5db13afd4d701f93349135dfec)) * update updateLocale plugin to merge nested object properties instead of replacing ([#3012](https://github.com/iamkun/dayjs/issues/3012)) ([99691c5](https://github.com/iamkun/dayjs/commit/99691c5f3bd1371d3b763d5f9dfaed9a1945a477)), closes [#1118](https://github.com/iamkun/dayjs/issues/1118) ## [1.11.19](https://github.com/iamkun/dayjs/compare/v1.11.18...v1.11.19) (2025-10-31) ### Bug Fixes * added usage warnings for diff + updated unit tests ([#2948](https://github.com/iamkun/dayjs/issues/2948)) ([269a7a9](https://github.com/iamkun/dayjs/commit/269a7a9cf3649b7a4b328e771173701764a8480d)) * dont instantiate regexes within ar locale functions to avoid performance overhead ([#2898](https://github.com/iamkun/dayjs/issues/2898)) ([af5e9f0](https://github.com/iamkun/dayjs/commit/af5e9f0e7649cbd1ecf707daab8303f2733f2563)) * replace italian locale "un' ora fa" with "un'ora fa", add tests for it ([#2930](https://github.com/iamkun/dayjs/issues/2930)) ([9e9f76c](https://github.com/iamkun/dayjs/commit/9e9f76cf117fa834260b30193434bc4481b4b6be)) * Updated Belarusian locale with relative time ([#2656](https://github.com/iamkun/dayjs/issues/2656)) ([1d8746c](https://github.com/iamkun/dayjs/commit/1d8746c23bd667bde80ee627a915301ebd69e1a2)) ## [1.11.18](https://github.com/iamkun/dayjs/compare/v1.11.17...v1.11.18) (2025-08-30) ### Bug Fixes * error semantic-release dependency ([8cfb313](https://github.com/iamkun/dayjs/commit/8cfb31386d840d31e9655870f4d8c01592eb753a)) ## [1.11.17](https://github.com/iamkun/dayjs/compare/v1.11.16...v1.11.17) (2025-08-29) ### Bug Fixes * [en-AU] locale use the same ordinal as moment ([#2878](https://github.com/iamkun/dayjs/issues/2878)) ([1b95ecd](https://github.com/iamkun/dayjs/commit/1b95ecd21d4feafe7ab113a2d48d7d8d93bb95c9)) ## [1.11.16](https://github.com/iamkun/dayjs/compare/v1.11.15...v1.11.16) (2025-08-29) ### Bug Fixes * test release workflow (no code changes) ([c38c428](https://github.com/iamkun/dayjs/commit/c38c428a78c344699eff373adfc8c007bb3a514f)) ## [1.11.15](https://github.com/iamkun/dayjs/compare/v1.11.14...v1.11.15) (2025-08-28) ### Bug Fixes * Fix misspellings in Irish or Irish Gaelic [ga] ([#2861](https://github.com/iamkun/dayjs/issues/2861)) ([9c14a42](https://github.com/iamkun/dayjs/commit/9c14a4245a8e764ee3260ff17a7ff48dfd09d279)) ## [1.11.14](https://github.com/iamkun/dayjs/compare/v1.11.13...v1.11.14) (2025-08-27) ### Bug Fixes * .utcOffset(0, true) result and its clone are different bug ([#2505](https://github.com/iamkun/dayjs/issues/2505)) ([fefdcd4](https://github.com/iamkun/dayjs/commit/fefdcd4b6b807786f65139b6dd801e0014d7dc6f)) ## [1.11.13](https://github.com/iamkun/dayjs/compare/v1.11.12...v1.11.13) (2024-08-20) ### Bug Fixes * customParseFormat supports Q quter / w ww weekOfYear ([#2705](https://github.com/iamkun/dayjs/issues/2705)) ([8ca74f1](https://github.com/iamkun/dayjs/commit/8ca74f178eff4bb4eb686676cf35fe7edb815536)) ## [1.11.12](https://github.com/iamkun/dayjs/compare/v1.11.11...v1.11.12) (2024-07-18) ### Bug Fixes * Add NegativeYear Plugin support ([#2640](https://github.com/iamkun/dayjs/issues/2640)) ([6a42e0d](https://github.com/iamkun/dayjs/commit/6a42e0d7398639238f575d51287daaf4d495a2a3)) * add UTC support to negativeYear plugin ([#2692](https://github.com/iamkun/dayjs/issues/2692)) ([f3ef705](https://github.com/iamkun/dayjs/commit/f3ef705613af83333fe132b470896a65e12f31b0)) * Fix zero offset issue when use tz with locale ([#2532](https://github.com/iamkun/dayjs/issues/2532)) ([d0e6738](https://github.com/iamkun/dayjs/commit/d0e6738a66e1b65d3706aad2f9168ebb43d4f887)) * Improve typing for min/max plugin ([#2573](https://github.com/iamkun/dayjs/issues/2573)) ([4fbe94a](https://github.com/iamkun/dayjs/commit/4fbe94aaba8c815a42cf4d23dabac918ec50e68c)) * timezone plugin correct parse UTC tz ([#2693](https://github.com/iamkun/dayjs/issues/2693)) ([b575c81](https://github.com/iamkun/dayjs/commit/b575c81a8c9c85c7a0baf6f608a12f9d3ba95bd1)) ## [1.11.11](https://github.com/iamkun/dayjs/compare/v1.11.10...v1.11.11) (2024-04-28) ### Bug Fixes * day of week type literal ([#2630](https://github.com/iamkun/dayjs/issues/2630)) ([f68d73e](https://github.com/iamkun/dayjs/commit/f68d73efe562fdedd9e288ecb0ce6565e602f507)) * improve locale "zh-hk" format and meridiem ([#2419](https://github.com/iamkun/dayjs/issues/2419)) ([a947a51](https://github.com/iamkun/dayjs/commit/a947a5171aad5695eaf593bc95fe073de0f0894a)) * Update 'da' locale to match correct first week of year ([#2592](https://github.com/iamkun/dayjs/issues/2592)) ([44b0936](https://github.com/iamkun/dayjs/commit/44b0936ad709212b63e48672d8b9c225e2c3b830)) * update locale Bulgarian monthsShort Jan ([#2538](https://github.com/iamkun/dayjs/issues/2538)) ([f0c9a41](https://github.com/iamkun/dayjs/commit/f0c9a41c6ec91528f3790e442b0c5dff15a4e640)) ## [1.11.10](https://github.com/iamkun/dayjs/compare/v1.11.9...v1.11.10) (2023-09-19) ### Bug Fixes * Add Korean Day of Month with ordinal ([#2395](https://github.com/iamkun/dayjs/issues/2395)) ([dd55ee2](https://github.com/iamkun/dayjs/commit/dd55ee2aadd1009242235e47d558bbf028827896)) * change back fa locale to the Gregorian calendar equivalent ([#2411](https://github.com/iamkun/dayjs/issues/2411)) ([95e9458](https://github.com/iamkun/dayjs/commit/95e9458b221fe35e59ee4a160a5db247313a68fb)) * duration plugin - MILLISECONDS_A_MONTH const calculation ([#2362](https://github.com/iamkun/dayjs/issues/2362)) ([f0a0b54](https://github.com/iamkun/dayjs/commit/f0a0b546b074b3b511c2319a1ce83d412894b91f)) * duration plugin getter get result 0 instead of undefined ([#2369](https://github.com/iamkun/dayjs/issues/2369)) ([061aa7e](https://github.com/iamkun/dayjs/commit/061aa7ed6c31696974665fc9b11a74d30841ebed)) * fix isDayjs check logic ([#2383](https://github.com/iamkun/dayjs/issues/2383)) ([5f3f878](https://github.com/iamkun/dayjs/commit/5f3f8786c796cd432fe6bcb6966a810daea89203)) * fix timezone plugin to get correct locale setting ([#2420](https://github.com/iamkun/dayjs/issues/2420)) ([4f45012](https://github.com/iamkun/dayjs/commit/4f4501256fa1bc72128aae1d841bbd782df86aed)) * **locale:** add meridiem in `ar` locale ([#2418](https://github.com/iamkun/dayjs/issues/2418)) ([361be5c](https://github.com/iamkun/dayjs/commit/361be5c7c628614ee833d710acbe154a598b904d)) * round durations to millisecond precision for ISO string ([#2367](https://github.com/iamkun/dayjs/issues/2367)) ([890a17a](https://github.com/iamkun/dayjs/commit/890a17a8d8ddd43c7c8b806e3afc7b27f3288d27)) * sub-second precisions need to be rounded at the seconds field to avoid adding floats ([#2377](https://github.com/iamkun/dayjs/issues/2377)) ([a9d7d03](https://github.com/iamkun/dayjs/commit/a9d7d0398d22ebd4bfc3812ca0134a97606d54d9)) * update $x logic to avoid plugin error ([#2429](https://github.com/iamkun/dayjs/issues/2429)) ([2254635](https://github.com/iamkun/dayjs/commit/22546357f30924fcff3b3ffa14fd04be21f97a5e)) * Update Slovenian locale for relative time ([#2396](https://github.com/iamkun/dayjs/issues/2396)) ([5470a15](https://github.com/iamkun/dayjs/commit/5470a15e437fac803797363063b24f3ba3bd5299)) * update uzbek language translation ([#2327](https://github.com/iamkun/dayjs/issues/2327)) ([0a91056](https://github.com/iamkun/dayjs/commit/0a910564d76dc7c128da8e0d85d8e11ebdb5660b)) ## [1.11.9](https://github.com/iamkun/dayjs/compare/v1.11.8...v1.11.9) (2023-07-01) ### Bug Fixes * Add null to min and max plugin return type ([#2355](https://github.com/iamkun/dayjs/issues/2355)) ([62d9042](https://github.com/iamkun/dayjs/commit/62d9042eb84b78d78324694ccbeaad1679d37e68)) * check if null passed to objectSupport parser ([#2175](https://github.com/iamkun/dayjs/issues/2175)) ([013968f](https://github.com/iamkun/dayjs/commit/013968f609c32e2269df69b4dd1feb2e8e1e035a)) * dayjs.diff improve performance ([#2244](https://github.com/iamkun/dayjs/issues/2244)) ([33c80e1](https://github.com/iamkun/dayjs/commit/33c80e14cf14f70ceb4f54639e266cd70a3c3996)) * dayjs(null) throws error, not return dayjs object as invalid date ([#2334](https://github.com/iamkun/dayjs/issues/2334)) ([c79e2f5](https://github.com/iamkun/dayjs/commit/c79e2f5d03eef5660b1f13385b69c0c9668d2f98)) * objectSupport plugin causes an error when null is passed to dayjs function (closes [#2277](https://github.com/iamkun/dayjs/issues/2277)) ([#2342](https://github.com/iamkun/dayjs/issues/2342)) ([89bf31c](https://github.com/iamkun/dayjs/commit/89bf31ce0a36dcfc892029dc019d85d3654cf5fb)) * Optimize format method ([#2313](https://github.com/iamkun/dayjs/issues/2313)) ([1fe1b1d](https://github.com/iamkun/dayjs/commit/1fe1b1d9a214d3b8c9f267b432801424a493f1c4)) * update Duration plugin add/subtract take into account days in month ([#2337](https://github.com/iamkun/dayjs/issues/2337)) ([3b1060f](https://github.com/iamkun/dayjs/commit/3b1060f92183ab3a3c49289c2d87fbdd34c1eacc)) * update MinMax plugin 1. ignore the 'null' in args 2. return the only one arg ([#2330](https://github.com/iamkun/dayjs/issues/2330)) ([3c2c6ee](https://github.com/iamkun/dayjs/commit/3c2c6ee4db00bbb43a7a3bb0b56bc0d0f03daddc)) ## [1.11.8](https://github.com/iamkun/dayjs/compare/v1.11.7...v1.11.8) (2023-06-02) ### Bug Fixes * .format add padding to 'YYYY' ([#2231](https://github.com/iamkun/dayjs/issues/2231)) ([00c223b](https://github.com/iamkun/dayjs/commit/00c223b7e92970d07557133994fcb225a6d4c960)) * Added .valueOf method to Duration class ([#2226](https://github.com/iamkun/dayjs/issues/2226)) ([9b4fcfd](https://github.com/iamkun/dayjs/commit/9b4fcfde35b39693894be1821b6c7222fac98657)) * timezone type mark `date` parameter as optional ([#2222](https://github.com/iamkun/dayjs/issues/2222)) ([b87aa0e](https://github.com/iamkun/dayjs/commit/b87aa0ed9a748c478a66ef48230cd1d6350d7b8a)) * type file first parameter date is optional in isSame(), isBefore(), isAfter() ([#2272](https://github.com/iamkun/dayjs/issues/2272)) ([4d56f3e](https://github.com/iamkun/dayjs/commit/4d56f3eb2b3770879d60f824590bf1b32f237d47)) ## [1.11.7](https://github.com/iamkun/dayjs/compare/v1.11.6...v1.11.7) (2022-12-06) ### Bug Fixes * Add locale (zh-tw) meridiem ([#2149](https://github.com/iamkun/dayjs/issues/2149)) ([1e9ba76](https://github.com/iamkun/dayjs/commit/1e9ba761ff4e3f2759106dfe1aa9054d5826451c)) * update fa locale ([#2151](https://github.com/iamkun/dayjs/issues/2151)) ([1c26732](https://github.com/iamkun/dayjs/commit/1c267321a1a01b4947e1482bac67d67ebc7c3dfa)) ## [1.11.6](https://github.com/iamkun/dayjs/compare/v1.11.5...v1.11.6) (2022-10-21) ### Bug Fixes * add BigIntSupport plugin ([#2087](https://github.com/iamkun/dayjs/issues/2087)) ([f6dce48](https://github.com/iamkun/dayjs/commit/f6dce48a9e39677718b087867d9fd901d5078155)) * Fix objectSupport collides with Duration plugin - issue [#2027](https://github.com/iamkun/dayjs/issues/2027) ([#2038](https://github.com/iamkun/dayjs/issues/2038)) ([c9370ea](https://github.com/iamkun/dayjs/commit/c9370ea96bf420439ee7eaa4146e8ed643160312)) ## [1.11.5](https://github.com/iamkun/dayjs/compare/v1.11.4...v1.11.5) (2022-08-12) ### Bug Fixes * ordinal for nl not working ([#2011](https://github.com/iamkun/dayjs/issues/2011)) ([c93c85e](https://github.com/iamkun/dayjs/commit/c93c85eaa11564a1aae2d823480a417812c01bf4)) * wrong ordinal for french locale ([#2010](https://github.com/iamkun/dayjs/issues/2010)) ([dd192a7](https://github.com/iamkun/dayjs/commit/dd192a72fc5d26ce56481e89b0c1ccf5f939be0c)) ## [1.11.4](https://github.com/iamkun/dayjs/compare/v1.11.3...v1.11.4) (2022-07-19) ### Bug Fixes * correct past property in ku (kurdish) locale ([#1916](https://github.com/iamkun/dayjs/issues/1916)) ([74e82b9](https://github.com/iamkun/dayjs/commit/74e82b9da5ec8b90361fc27ac7c8b63faf354502)) * fix French [fr] local ordinal ([#1932](https://github.com/iamkun/dayjs/issues/1932)) ([8f09834](https://github.com/iamkun/dayjs/commit/8f09834a88b8e7f8353c6e7473d4711596890a8c)) * fix objectSupport plugin ConfigTypeMap type ([#1441](https://github.com/iamkun/dayjs/issues/1441)) ([#1990](https://github.com/iamkun/dayjs/issues/1990)) ([fd51fe4](https://github.com/iamkun/dayjs/commit/fd51fe4f7fa799d8c598343e71fa59299ec4cf93)) * fix type error to add ordianl property in InstanceLocaleDataReturn and GlobalLocaleDataReturn types ([#1931](https://github.com/iamkun/dayjs/issues/1931)) ([526f0ae](https://github.com/iamkun/dayjs/commit/526f0ae549ffbeeb9ef1099ca23964791fc59743)) * update locale ar-* meridiem function ([#1954](https://github.com/iamkun/dayjs/issues/1954)) ([3d31611](https://github.com/iamkun/dayjs/commit/3d316117f04362d31f4e8bd349620b8414ce5d0c)) * zh-tw / zh-hk locale ordinal error ([#1976](https://github.com/iamkun/dayjs/issues/1976)) ([0a1bd08](https://github.com/iamkun/dayjs/commit/0a1bd08e736be7d4e378aaca280caa6543f8066d)) ## [1.11.3](https://github.com/iamkun/dayjs/compare/v1.11.2...v1.11.3) (2022-06-06) ### Bug Fixes * customParseFormat plugin to parse comma as a separator character ([#1913](https://github.com/iamkun/dayjs/issues/1913)) ([41b1405](https://github.com/iamkun/dayjs/commit/41b1405971e099431211ae6c2a100cd797da4427)) * update Dutch [nl] locale ordinal ([#1908](https://github.com/iamkun/dayjs/issues/1908)) ([5da98f8](https://github.com/iamkun/dayjs/commit/5da98f8085d2d2847d79e38c795082703a14f24b)) ## [1.11.2](https://github.com/iamkun/dayjs/compare/v1.11.1...v1.11.2) (2022-05-06) ### Bug Fixes * add OpUnitType (week) to quarterOfYear startOf/endOf types ([#1865](https://github.com/iamkun/dayjs/issues/1865)) ([400bc3e](https://github.com/iamkun/dayjs/commit/400bc3e8915e0c58e7abbfd3a1235364b1abaf3e)) * Fix type issue with ManipulateType ([#1864](https://github.com/iamkun/dayjs/issues/1864)) ([d033dfc](https://github.com/iamkun/dayjs/commit/d033dfcfc1d2ced39b2733898e8d85ad5984c9e9)) * fix UTC plugin .valueOf not taking DST into account ([#1448](https://github.com/iamkun/dayjs/issues/1448)) ([27d1c50](https://github.com/iamkun/dayjs/commit/27d1c506100ae6624f258c21cc06b24768ced733)) ## [1.11.1](https://github.com/iamkun/dayjs/compare/v1.11.0...v1.11.1) (2022-04-15) ### Bug Fixes * add Bengali (Bangladesh) [bn-bd] locale ([#1806](https://github.com/iamkun/dayjs/issues/1806)) ([840ed76](https://github.com/iamkun/dayjs/commit/840ed76eedc085afefc4dedd05f31d44196b63b0)) * refactor replace deprecated String.prototype.substr() ([#1836](https://github.com/iamkun/dayjs/issues/1836)) ([627fa39](https://github.com/iamkun/dayjs/commit/627fa393e4daf83c92431162dbe18534b23fcbae)) * Update German [de] locale, adds the abbreviations for month including a . in the end, as in September -> Sept. ([#1831](https://github.com/iamkun/dayjs/issues/1831)) ([4e2802c](https://github.com/iamkun/dayjs/commit/4e2802cc3bec2941ffb737a15fb531c90951eafe)) * update Italian (Switzerland) [it-ch] locale relativeTime ([#1829](https://github.com/iamkun/dayjs/issues/1829)) ([8e6d11d](https://github.com/iamkun/dayjs/commit/8e6d11d053393d97bee1ba411adb2d82de1a58c4)) * update Kurdish [ku] locale strings and formatted output contains non-standard kurdish characters ([#1848](https://github.com/iamkun/dayjs/issues/1848)) ([a597d0b](https://github.com/iamkun/dayjs/commit/a597d0b1b8dd28e626f8c59d326622088f7b51e7)) * update locale bo [Tibetan]: corrected the orders in formats ([#1823](https://github.com/iamkun/dayjs/issues/1823)) ([e790516](https://github.com/iamkun/dayjs/commit/e79051617af6787358f6c9b5443d987b8b53a9e1)) # [1.11.0](https://github.com/iamkun/dayjs/compare/v1.10.8...v1.11.0) (2022-03-14) ### Bug Fixes * Add Kirundi (rn) locale ([#1793](https://github.com/iamkun/dayjs/issues/1793)) ([74e5247](https://github.com/iamkun/dayjs/commit/74e5247227a779fffde39bdfcd1ee19911496709)) * add missing date shorthand D type definition ([#1752](https://github.com/iamkun/dayjs/issues/1752)) ([b045baf](https://github.com/iamkun/dayjs/commit/b045baf1646a81f7e4f446f355d02d5fb0ef4aa7)) * Add relative time to Galician (gl) and fix ordinals ([#1800](https://github.com/iamkun/dayjs/issues/1800)) ([dcbf170](https://github.com/iamkun/dayjs/commit/dcbf1708400624addfbddbc71e0f6a9ac15fa961)) * update German locales (de-at, de-ch) ([#1775](https://github.com/iamkun/dayjs/issues/1775)) ([f9055a7](https://github.com/iamkun/dayjs/commit/f9055a77bf3d84c575e5fcf99e21611138ba64d7)) * update Icelandic [is] locale relativeTime config ([#1796](https://github.com/iamkun/dayjs/issues/1796)) ([76f9e17](https://github.com/iamkun/dayjs/commit/76f9e1756de7e99c01e471dab30ea074b9ec9629)) * Update index.d.ts note ([#1716](https://github.com/iamkun/dayjs/issues/1716)) ([5a108ff](https://github.com/iamkun/dayjs/commit/5a108ff3159c53fd270ea7638f33c35c934d6457)) * Update locale German [de] monthsShort ([#1746](https://github.com/iamkun/dayjs/issues/1746)) ([4a7b7d0](https://github.com/iamkun/dayjs/commit/4a7b7d07c885bb9338514c234dbb708e24e9863e)) * update meridiem function to Kurdish (ku) locale ([#1725](https://github.com/iamkun/dayjs/issues/1725)) ([efd3904](https://github.com/iamkun/dayjs/commit/efd3904ff8cbf0a4fc064911dda76fc86b669f7b)) * update updateLocal plugin typescript types ([#1692](https://github.com/iamkun/dayjs/issues/1692)) ([c7a3f73](https://github.com/iamkun/dayjs/commit/c7a3f73064dbb63b4d365b2ad4c792f075f4d8d8)) ### Features * Fallback to language only locale + support uppercase locales ([#1524](https://github.com/iamkun/dayjs/issues/1524)) ([9138dc2](https://github.com/iamkun/dayjs/commit/9138dc28206875372da4fb74c64716437cd11b95)) ## [1.10.8](https://github.com/iamkun/dayjs/compare/v1.10.7...v1.10.8) (2022-02-28) ### Bug Fixes * set locale pt, pt-br correct weekdays and months ([#1697](https://github.com/iamkun/dayjs/issues/1697)) ([e019301](https://github.com/iamkun/dayjs/commit/e01930171c8235f58a114236f146086428f99569)) ## [1.10.7](https://github.com/iamkun/dayjs/compare/v1.10.6...v1.10.7) (2021-09-10) ### Bug Fixes * Add Spanish (Mexico) [es-mx] locale ([#1614](https://github.com/iamkun/dayjs/issues/1614)) ([3393f2a](https://github.com/iamkun/dayjs/commit/3393f2ad55346d55902683a2e31c6f253d96c8c2)) * Add Arabic (Iraq) [ar-iq] locale ([#1627](https://github.com/iamkun/dayjs/issues/1627)) ([b5a1391](https://github.com/iamkun/dayjs/commit/b5a1391011b247d08863d291542db5937b23b427)) * add format object type to type file ([#1572](https://github.com/iamkun/dayjs/issues/1572)) ([5a79cc6](https://github.com/iamkun/dayjs/commit/5a79cc6408e825d9e123629eb44fc19c996d7751)) * duration plugin when parsing duration from ISO string, set missing components to 0 instead of NaN ([#1611](https://github.com/iamkun/dayjs/issues/1611)) ([252585b](https://github.com/iamkun/dayjs/commit/252585b4b2bd59508150e21bb994908a9d78f9b0)) * narrow type for `add` and `subtract` ([#1576](https://github.com/iamkun/dayjs/issues/1576)) ([1686962](https://github.com/iamkun/dayjs/commit/16869621b1a42563064dbf87f80c1ebfd74c1188)) * update customParseFormat plugin strict x X parsing ([#1571](https://github.com/iamkun/dayjs/issues/1571)) ([08adda5](https://github.com/iamkun/dayjs/commit/08adda54edbcca38601f57841921d0f87f84e49e)) * update Lithuanian [lt] locale spelling for single month ([#1609](https://github.com/iamkun/dayjs/issues/1609)) ([255dc54](https://github.com/iamkun/dayjs/commit/255dc54d9295de135a9037ce6ca13cae4bfd2cfb)) * Update Norwegian Bokmål [nb] local yearStart 4 ([#1608](https://github.com/iamkun/dayjs/issues/1608)) ([7a8467c](https://github.com/iamkun/dayjs/commit/7a8467c0b7d59821f7e19d4a6973bcda8e4c19b1)) * update plugin advancedFormat `isValid` validation ([#1566](https://github.com/iamkun/dayjs/issues/1566)) ([755fc8b](https://github.com/iamkun/dayjs/commit/755fc8bb1c532eb991459f180eee81367d12016c)) * update Sinhalese [si] locale month name ([#1475](https://github.com/iamkun/dayjs/issues/1475)) ([63de2a8](https://github.com/iamkun/dayjs/commit/63de2a8b7dcd7e68c132c85d88572d4c9d296907)) * update utcOffset plugin type file ([#1604](https://github.com/iamkun/dayjs/issues/1604)) ([f68e4b1](https://github.com/iamkun/dayjs/commit/f68e4b1a29fc33542f74cde10ec6d9fb045ca37e)) ## [1.10.6](https://github.com/iamkun/dayjs/compare/v1.10.5...v1.10.6) (2021-07-06) ### Bug Fixes * add invalid date string override ([#1465](https://github.com/iamkun/dayjs/issues/1465)) ([#1470](https://github.com/iamkun/dayjs/issues/1470)) ([06f88f4](https://github.com/iamkun/dayjs/commit/06f88f425828b1ce96b737332d25145a95a4ee9d)) * add sv-fi Finland Swedish locale ([#1522](https://github.com/iamkun/dayjs/issues/1522)) ([8e32164](https://github.com/iamkun/dayjs/commit/8e32164855cff724642e24c37a631eb4c4d760c8)) * customParseFormat support parsing X x timestamp ([#1567](https://github.com/iamkun/dayjs/issues/1567)) ([eb087f5](https://github.com/iamkun/dayjs/commit/eb087f52861313b8dd8a5c1b77858665ec72859e)) * dayjs ConfigTypeMap add null & undefined ([#1560](https://github.com/iamkun/dayjs/issues/1560)) ([b5e40e6](https://github.com/iamkun/dayjs/commit/b5e40e6f16abeaea6a0facfa466d20aefaa8a444)) * Fix DayOfYear plugin when using BadMutable plugin ([#1511](https://github.com/iamkun/dayjs/issues/1511)) ([0b0c6a3](https://github.com/iamkun/dayjs/commit/0b0c6a31ec9c0aff991b0e8dd6eed116201274cc)) * Implement ordinal in Bulgarian translation (fixes [#1501](https://github.com/iamkun/dayjs/issues/1501)) ([#1502](https://github.com/iamkun/dayjs/issues/1502)) ([b728da5](https://github.com/iamkun/dayjs/commit/b728da5ed9ed08210004ed20ce5fcd52a92de7da)) * more strict delimiter in REGEX_PARSE ([#1555](https://github.com/iamkun/dayjs/issues/1555)) ([bfdab5c](https://github.com/iamkun/dayjs/commit/bfdab5c0d45a5736b68e8e1b1354fc021e05f607)) * parameter type ([#1549](https://github.com/iamkun/dayjs/issues/1549)) ([f369844](https://github.com/iamkun/dayjs/commit/f369844dd69d253c4c7cbf68150939db3db233be)) * update customParseFormat plugin to custom two-digit year parse function ([#1421](https://github.com/iamkun/dayjs/issues/1421)) ([bb5df55](https://github.com/iamkun/dayjs/commit/bb5df55cd3975dc7638b8f4e762afa470b6620f7)) * update names of weekdays and months in Bulgarian [bg] to lowercase ([#1438](https://github.com/iamkun/dayjs/issues/1438)) ([b246210](https://github.com/iamkun/dayjs/commit/b24621091fec9cf6704de21e4b323f6f0c4abbf1)) * update type file `.diff` ([#1505](https://github.com/iamkun/dayjs/issues/1505)) ([6508494](https://github.com/iamkun/dayjs/commit/6508494a4e62977b4397baaeef293d1bcf3c7235)) * update UTC plugin type file for strict parsing ([#1443](https://github.com/iamkun/dayjs/issues/1443)) ([b4f28df](https://github.com/iamkun/dayjs/commit/b4f28df219fe63202dffdbeeaec5677c4d2c9111)) ## [1.10.5](https://github.com/iamkun/dayjs/compare/v1.10.4...v1.10.5) (2021-05-26) ### Bug Fixes * add meridiem in ar locales ([#1375](https://github.com/iamkun/dayjs/issues/1375)) ([319f616](https://github.com/iamkun/dayjs/commit/319f616e572a03b984013d04d1b3a18ffd5b1190)) * Added Zulu support to customParseFormat ([#1359](https://github.com/iamkun/dayjs/issues/1359)) ([1138a3f](https://github.com/iamkun/dayjs/commit/1138a3f0a76592c6d72fb86c4399e133fa41e2ec)) * fix Bengali [bn] locale monthsShort error ([a0e6c0c](https://github.com/iamkun/dayjs/commit/a0e6c0cf3e1828020dfa11432c6716990f6ed5e0)) * fix missing types for ArraySupport plugin ([#1401](https://github.com/iamkun/dayjs/issues/1401)) ([b1abdc4](https://github.com/iamkun/dayjs/commit/b1abdc40ee6c9d18ff46c311a114e0755677ea6f)) * fix Ukrainian [uk] locale ([#1463](https://github.com/iamkun/dayjs/issues/1463)) ([0fdac93](https://github.com/iamkun/dayjs/commit/0fdac93ff2531542301b76952be9b084b2e2dfa0)) * hotfix for `Duration` types ([#1357](https://github.com/iamkun/dayjs/issues/1357)) ([855b7b3](https://github.com/iamkun/dayjs/commit/855b7b3d049a3903794f91db3419f167c00dabd2)), closes [#1354](https://github.com/iamkun/dayjs/issues/1354) * timezone plugin DST error ([#1352](https://github.com/iamkun/dayjs/issues/1352)) ([71bed15](https://github.com/iamkun/dayjs/commit/71bed155edf32bff24379930ac684fc783538d8f)) * Update duration plugin change string to number ([#1394](https://github.com/iamkun/dayjs/issues/1394)) ([e1546d1](https://github.com/iamkun/dayjs/commit/e1546d1a0cdb97ae92cf11efe61d94707af6a3a3)) * update Duration plugin to support no-argument ([#1400](https://github.com/iamkun/dayjs/issues/1400)) ([8d9a5ae](https://github.com/iamkun/dayjs/commit/8d9a5ae0749e1b4e76babd4deeaa3b1d9776c29b)) * Update Finnish [fi] locale to set yearStart ([#1378](https://github.com/iamkun/dayjs/issues/1378)) ([f3370bd](https://github.com/iamkun/dayjs/commit/f3370bda4e435118f714c8a7daf5c88cfc4b69ba)) * update Russian [ru] locale meridiem and unit tests ([#1403](https://github.com/iamkun/dayjs/issues/1403)) ([f10f39d](https://github.com/iamkun/dayjs/commit/f10f39de7db70244a3c35e4a421090a12972457b)) * update Russian [ru] locale yearStart config ([#1372](https://github.com/iamkun/dayjs/issues/1372)) ([5052515](https://github.com/iamkun/dayjs/commit/5052515fe35b2444201ef8ef87220b1876a94d0a)) * update Slovenian [sl] locale to set correct ordinal ([#1386](https://github.com/iamkun/dayjs/issues/1386)) ([cb4f746](https://github.com/iamkun/dayjs/commit/cb4f74633b3020d6dbf19548c8cb13613dafca18)) * update Spanish [es] locale to change month names to lowercase ([#1414](https://github.com/iamkun/dayjs/issues/1414)) ([9c20e77](https://github.com/iamkun/dayjs/commit/9c20e77caf7b1b5eccf418175203b198d4e29535)) * update Swedish [sv] locale to set correct yearStart ([#1385](https://github.com/iamkun/dayjs/issues/1385)) ([66c5935](https://github.com/iamkun/dayjs/commit/66c59354964ef456bcd5f6152819618f44978082)) * update UTC plugin to support string argument like +HH:mm ([#1395](https://github.com/iamkun/dayjs/issues/1395)) ([656127c](https://github.com/iamkun/dayjs/commit/656127cc44eda50923a1ac755602863fc32b9e69)) ## [1.10.4](https://github.com/iamkun/dayjs/compare/v1.10.3...v1.10.4) (2021-01-22) ### Bug Fixes * Correct handling negative duration ([#1317](https://github.com/iamkun/dayjs/issues/1317)) ([3f5c085](https://github.com/iamkun/dayjs/commit/3f5c085608182472f20b84766b10949945663e44)) * Improve `Duration` types ([#1338](https://github.com/iamkun/dayjs/issues/1338)) ([4aca4b1](https://github.com/iamkun/dayjs/commit/4aca4b1b584a15de1146d929f95c944594032f20)) * parse a string for MMM month format with underscore delimiter ([#1349](https://github.com/iamkun/dayjs/issues/1349)) ([82ef9a3](https://github.com/iamkun/dayjs/commit/82ef9a304f06287ac0a14c4da9a7fe6152b5fec9)) * Update Bengali [bn] locale ([#1329](https://github.com/iamkun/dayjs/issues/1329)) ([02d96ec](https://github.com/iamkun/dayjs/commit/02d96ec7189f62d6ef8987135919cbb5ceff20a6)) * update locale Portuguese [pt] yearStart ([#1345](https://github.com/iamkun/dayjs/issues/1345)) ([5c785d5](https://github.com/iamkun/dayjs/commit/5c785d528cc08811638d7cbfc7fc158d67b32d75)) * update Polish [pl] locale yearStart ([#1348](https://github.com/iamkun/dayjs/issues/1348)) ([e93e6b8](https://github.com/iamkun/dayjs/commit/e93e6b8ffa61036b26382f1763e3864d4a7d5df5)) * Update Slovenian [sl] relativeTime locale ([#1333](https://github.com/iamkun/dayjs/issues/1333)) ([fe5f1d0](https://github.com/iamkun/dayjs/commit/fe5f1d0afbe57b70339e268047e6c3028ca3d59b)) ## [1.10.3](https://github.com/iamkun/dayjs/compare/v1.10.2...v1.10.3) (2021-01-09) ### Bug Fixes * fix customParseFormat plugin strict mode parse meridiem bug ([#1321](https://github.com/iamkun/dayjs/issues/1321)) ([e49eeef](https://github.com/iamkun/dayjs/commit/e49eeefbe8acb36419d36ca2e7ed8bc152f73ac1)) * fix weekYear plugin missing locale bug ([#1319](https://github.com/iamkun/dayjs/issues/1319)) ([344bdc0](https://github.com/iamkun/dayjs/commit/344bdc0eed6843edb05723dc7853a41833d88f08)), closes [#1304](https://github.com/iamkun/dayjs/issues/1304) * update advancedFormat plugin to add format options for iso week and weekyear ([#1309](https://github.com/iamkun/dayjs/issues/1309)) ([2c54c64](https://github.com/iamkun/dayjs/commit/2c54c6441871a175ac9b95e41e4cd075dbac10cb)) * update devHelper to add dev warning setting locale before loading ([c5cc893](https://github.com/iamkun/dayjs/commit/c5cc89355e1e206ca72433c19c40cb528690b04f)) * update German [de] locale yearStart ([1858df8](https://github.com/iamkun/dayjs/commit/1858df8008de56570680723df89b36a8cbc970ef)), closes [#1264](https://github.com/iamkun/dayjs/issues/1264) ## [1.10.2](https://github.com/iamkun/dayjs/compare/v1.10.1...v1.10.2) (2021-01-05) ### Bug Fixes * fix parse regex bug ([#1307](https://github.com/iamkun/dayjs/issues/1307)) ([db2b6a5](https://github.com/iamkun/dayjs/commit/db2b6a5ea8e70f9fda645d113ca33495aa96b616)), closes [#1305](https://github.com/iamkun/dayjs/issues/1305) * remove module entry in package.json to revert 1.10.1 change ([#1314](https://github.com/iamkun/dayjs/issues/1314)) ([824dcb8](https://github.com/iamkun/dayjs/commit/824dcb8dfcccf14f64b6a2741a00fcdfe53dcd98)) * update devHelper add warning "passing Year as a Number will be parsed as a Unix timestamp" ([#1315](https://github.com/iamkun/dayjs/issues/1315)) ([b0dda31](https://github.com/iamkun/dayjs/commit/b0dda3139e25441ab4e7c1f4f192dee0ecce6ef8)) ## [1.10.1](https://github.com/iamkun/dayjs/compare/v1.10.0...v1.10.1) (2021-01-03) ### Bug Fixes * fix typescript type error UnitTypeLongPlural ([#1302](https://github.com/iamkun/dayjs/issues/1302)) ([bfaabe4](https://github.com/iamkun/dayjs/commit/bfaabe4f398c11564eca6cda7c8aded22e1b231a)), closes [#1300](https://github.com/iamkun/dayjs/issues/1300) # [1.10.0](https://github.com/iamkun/dayjs/compare/v1.9.8...v1.10.0) (2021-01-03) ### Bug Fixes * add ordinal to localeData plugin ([#1266](https://github.com/iamkun/dayjs/issues/1266)) ([fd229fa](https://github.com/iamkun/dayjs/commit/fd229fa5bd26bcba810e2535eb937ea8d99106c2)) * add preParsePostFormat plugin & update Arabic [ar] locale ([#1255](https://github.com/iamkun/dayjs/issues/1255)) ([f2e4790](https://github.com/iamkun/dayjs/commit/f2e479006a9a49bc0917f8620101d40ac645f7f2)) * add type support for plural forms of units ([#1289](https://github.com/iamkun/dayjs/issues/1289)) ([de49bb1](https://github.com/iamkun/dayjs/commit/de49bb100badfb92b9a5933cc568841f340a923f)) * escape last period to match only milliseconds ([#1239](https://github.com/iamkun/dayjs/issues/1239)) ([#1295](https://github.com/iamkun/dayjs/issues/1295)) ([64037e6](https://github.com/iamkun/dayjs/commit/64037e6a8cf303dcfd2b954f309bd9691f87fffc)) ### Features * add ES6 Module Support, package.json module point to "esm/index.js" ([#1298](https://github.com/iamkun/dayjs/issues/1298)) ([f63375d](https://github.com/iamkun/dayjs/commit/f63375dea89becbd3bb2bb8ea7289c58c752bfed)), closes [#598](https://github.com/iamkun/dayjs/issues/598) [#313](https://github.com/iamkun/dayjs/issues/313) ## [1.9.8](https://github.com/iamkun/dayjs/compare/v1.9.7...v1.9.8) (2020-12-27) ### Bug Fixes * fix Ukrainian [uk] locale typo ([1605cc0](https://github.com/iamkun/dayjs/commit/1605cc0f6fe0e9c46a92d529bc9cd6e130432337)) * update Hebrew [he] locale for double units ([#1287](https://github.com/iamkun/dayjs/issues/1287)) ([1c4b0da](https://github.com/iamkun/dayjs/commit/1c4b0da1468522e59dc9ee646d10dd2b31477d99)) * update zh locale meridiem "noon" ([0e7ff3d](https://github.com/iamkun/dayjs/commit/0e7ff3dd29ca3aed85cb76dfcb8298d326e26542)) * update zh-cn locale definition of noon ([#1278](https://github.com/iamkun/dayjs/issues/1278)) ([d5930b9](https://github.com/iamkun/dayjs/commit/d5930b96ff884f4176ca3fcb1bc95e8f1ec75c71)) ## [1.9.7](https://github.com/iamkun/dayjs/compare/v1.9.6...v1.9.7) (2020-12-05) ### Bug Fixes * add duration.format to format a Duration ([#1202](https://github.com/iamkun/dayjs/issues/1202)) ([9a859a1](https://github.com/iamkun/dayjs/commit/9a859a147ba223a1eeff0f2bb6f33d97e0ccc6c7)) * Add function handling for relativeTime.future and relativeTime.past ([#1197](https://github.com/iamkun/dayjs/issues/1197)) ([ef1979c](https://github.com/iamkun/dayjs/commit/ef1979ce85c61fe2d759ef3c37cb6aaf2358094f)) * avoid install installed plugin ([#1214](https://github.com/iamkun/dayjs/issues/1214)) ([a92eb6c](https://github.com/iamkun/dayjs/commit/a92eb6c4dc1437ec920e69484d52984f5921a8ea)) * avoid memory leak after installing a plugin too many times ([b8d2e32](https://github.com/iamkun/dayjs/commit/b8d2e32a9eb59661a7ed6200daa070687becaebd)) * fix diff bug when UTC plugin enabled ([#1201](https://github.com/iamkun/dayjs/issues/1201)) ([9544ed2](https://github.com/iamkun/dayjs/commit/9544ed2a6c466b8308d26b33a388a6737435a1f4)), closes [#1200](https://github.com/iamkun/dayjs/issues/1200) * fix startOf/endOf bug in timezone plugin ([#1229](https://github.com/iamkun/dayjs/issues/1229)) ([eb5fbc4](https://github.com/iamkun/dayjs/commit/eb5fbc4c7d1b62a8615d2f263b404a9515d8e15c)) * fix utc plugin diff edge case ([#1187](https://github.com/iamkun/dayjs/issues/1187)) ([971b3d4](https://github.com/iamkun/dayjs/commit/971b3d40b4c9403165138f1034e2223cd97c3abf)) * update customParseFormat plugin to parse 2-digit offset ([#1209](https://github.com/iamkun/dayjs/issues/1209)) ([b56936a](https://github.com/iamkun/dayjs/commit/b56936ab77b8f6289a1b77d49307b495c4bf9f91)), closes [#1205](https://github.com/iamkun/dayjs/issues/1205) * Update timezone plugin type definition ([#1221](https://github.com/iamkun/dayjs/issues/1221)) ([34cfb92](https://github.com/iamkun/dayjs/commit/34cfb920b9653ad44d4b31fe49e533692a3ce01b)) ## [1.9.6](https://github.com/iamkun/dayjs/compare/v1.9.5...v1.9.6) (2020-11-10) ### Bug Fixes * fix customParseFormat plugin parsing date bug ([#1198](https://github.com/iamkun/dayjs/issues/1198)) ([50f05ad](https://github.com/iamkun/dayjs/commit/50f05ad3addf27827c5657ae7519514e40d9faec)), closes [#1194](https://github.com/iamkun/dayjs/issues/1194) * Update lv (Latvian) locale relative time ([#1192](https://github.com/iamkun/dayjs/issues/1192)) ([6d6c684](https://github.com/iamkun/dayjs/commit/6d6c6841b13ba4f7e69de92caf132a3592c5253a)) ## [1.9.5](https://github.com/iamkun/dayjs/compare/v1.9.4...v1.9.5) (2020-11-05) ### Bug Fixes * customParseFormat plugin supports parsing localizedFormats ([#1110](https://github.com/iamkun/dayjs/issues/1110)) ([402b603](https://github.com/iamkun/dayjs/commit/402b603aa3ee4199786950bc88b3fdc6b527aa35)) * fix customParseFormat plugin parse meridiem bug ([#1169](https://github.com/iamkun/dayjs/issues/1169)) ([9e8f8d9](https://github.com/iamkun/dayjs/commit/9e8f8d96c69d557f4d267f42567c25ae9e7ab227)), closes [#1168](https://github.com/iamkun/dayjs/issues/1168) * fix devHelper error in umd bundle in browser ([#1165](https://github.com/iamkun/dayjs/issues/1165)) ([d11b5ee](https://github.com/iamkun/dayjs/commit/d11b5ee7dc11af671355f65ccda00f6ba42cc725)) * fix utc plugin diff bug in DST ([#1171](https://github.com/iamkun/dayjs/issues/1171)) ([f8da3fe](https://github.com/iamkun/dayjs/commit/f8da3fe7e50c84c0502bf5be0b364910922dbd79)), closes [#1097](https://github.com/iamkun/dayjs/issues/1097) [#1021](https://github.com/iamkun/dayjs/issues/1021) * isoWeek plugin type ([#1177](https://github.com/iamkun/dayjs/issues/1177)) ([c3d0436](https://github.com/iamkun/dayjs/commit/c3d0436b06f74989e3a2c751a5d170f8072c4aad)) * update localeData plugin to support meridiem ([#1174](https://github.com/iamkun/dayjs/issues/1174)) ([fdb09e4](https://github.com/iamkun/dayjs/commit/fdb09e4074cc7e8f6196846f18d3566c1f9e8fcd)), closes [#1172](https://github.com/iamkun/dayjs/issues/1172) * update timezone plugin parse Date instance / timestamp logic & remove useless test ([#1183](https://github.com/iamkun/dayjs/issues/1183)) ([a7f858b](https://github.com/iamkun/dayjs/commit/a7f858bb70ad81f718ba35c479e84b54eace48b2)) ## [1.9.4](https://github.com/iamkun/dayjs/compare/v1.9.3...v1.9.4) (2020-10-23) ### Bug Fixes * Add descriptions to types ([#1148](https://github.com/iamkun/dayjs/issues/1148)) ([9a407a1](https://github.com/iamkun/dayjs/commit/9a407a140b089345a387d1aceab4d0d1635229c7)) * add devHelper plugin ([#1163](https://github.com/iamkun/dayjs/issues/1163)) ([de49dc8](https://github.com/iamkun/dayjs/commit/de49dc80c83b85de4170571b64412bd60ada221b)) * Fix Hungarian (hu) locale ([#1112](https://github.com/iamkun/dayjs/issues/1112)) ([ab13754](https://github.com/iamkun/dayjs/commit/ab13754f43c5033dacaa0eb2042dc4ab1a7a2754)) * fix minMax plugin parsing empty array bug ([#1062](https://github.com/iamkun/dayjs/issues/1062)) ([368108b](https://github.com/iamkun/dayjs/commit/368108bc6d5cb1542f711b8eba722bd4dfaab0cd)) * update adding/subtracting Duration from Dayjs object ([#1156](https://github.com/iamkun/dayjs/issues/1156)) ([f861aca](https://github.com/iamkun/dayjs/commit/f861acac3e83e28d3a4a96312c71119fd6b544fc)) * update en-NZ locale to use proper ordinal formatting function ([#1143](https://github.com/iamkun/dayjs/issues/1143)) ([fcdbc58](https://github.com/iamkun/dayjs/commit/fcdbc5880710456a29b2bacf250542230bf48b99)) * update localeData plugin type ([#1116](https://github.com/iamkun/dayjs/issues/1116)) ([ee5a4ec](https://github.com/iamkun/dayjs/commit/ee5a4ec41edddfb57d103c35182dc635c9264a10)) * update timezone plugin to support custom parse format ([#1160](https://github.com/iamkun/dayjs/issues/1160)) ([48cbf31](https://github.com/iamkun/dayjs/commit/48cbf3118ba5427de428777c2e025896db654f2e)), closes [#1159](https://github.com/iamkun/dayjs/issues/1159) * update timezone plugin to support keepLocalTime ([#1161](https://github.com/iamkun/dayjs/issues/1161)) ([1d429e5](https://github.com/iamkun/dayjs/commit/1d429e5fe4467ebddcf81b43cf6f36e5e3be944c)), closes [#1149](https://github.com/iamkun/dayjs/issues/1149) ## [1.9.3](https://github.com/iamkun/dayjs/compare/v1.9.2...v1.9.3) (2020-10-13) ### Bug Fixes * fix localizedFormat export error ([#1133](https://github.com/iamkun/dayjs/issues/1133)) ([deecd6a](https://github.com/iamkun/dayjs/commit/deecd6ab8a2f4173ee7046f6b568b41fd2677531)), closes [#1132](https://github.com/iamkun/dayjs/issues/1132) ## [1.9.2](https://github.com/iamkun/dayjs/compare/v1.9.1...v1.9.2) (2020-10-13) ### Bug Fixes * add arraySupport plugin ([#1129](https://github.com/iamkun/dayjs/issues/1129)) ([be505c2](https://github.com/iamkun/dayjs/commit/be505c2c540261027342cecc55d8919a3d18d893)) * export type of duration plugin ([#1094](https://github.com/iamkun/dayjs/issues/1094)) ([2c92e71](https://github.com/iamkun/dayjs/commit/2c92e71bf55d09601120cdf433da7a19cc8abff6)) * Fix LocaleData plugin longDateFormat lowercase error ([#1101](https://github.com/iamkun/dayjs/issues/1101)) ([7937ccd](https://github.com/iamkun/dayjs/commit/7937ccdeac47d094a60e65ebb62a6020b81c46f4)) * Fix objectSupport plugin bug in UTC ([#1107](https://github.com/iamkun/dayjs/issues/1107)) ([fe90bb6](https://github.com/iamkun/dayjs/commit/fe90bb6944f2ff1969ca975954d303b449dfa95b)), closes [#1105](https://github.com/iamkun/dayjs/issues/1105) * fix Serbian locale grammar (sr, sr-cyrl) ([#1108](https://github.com/iamkun/dayjs/issues/1108)) ([cc87eff](https://github.com/iamkun/dayjs/commit/cc87eff8b75b0d86ce0956516319d402bccae6c0)) * Fix typo for "monday" in arabic ([#1067](https://github.com/iamkun/dayjs/issues/1067)) ([2e1e426](https://github.com/iamkun/dayjs/commit/2e1e42650124f30282dc4d710798d576b928f1c7)) * support dayjs.add(Duration), dayjs.subtract(Duration) ([#1099](https://github.com/iamkun/dayjs/issues/1099)) ([b1a0294](https://github.com/iamkun/dayjs/commit/b1a02942c5238203aaa04ce9a074c73742324ab7)) * update Breton [br] locale relativeTime config ([#1103](https://github.com/iamkun/dayjs/issues/1103)) ([b038bfd](https://github.com/iamkun/dayjs/commit/b038bfdb128889d677c95534d2be29cc30c9e72f)) * update Catalan [ca] locale ordinal ([73da380](https://github.com/iamkun/dayjs/commit/73da38024c8b550bdcfbe3ff7e578e742c7aecf2)) * update German [de] locale relativeTime config ([#1109](https://github.com/iamkun/dayjs/issues/1109)) ([f6e771b](https://github.com/iamkun/dayjs/commit/f6e771b70f93d19ebb12e6b794aa4628a1796248)) * update localeData plugin to add longDateFormat to global localeData ([#1106](https://github.com/iamkun/dayjs/issues/1106)) ([16937d1](https://github.com/iamkun/dayjs/commit/16937d16e053b8c1d4a607622fa2fdbfd9809832)) * Update objectSupport plugin to return current date time while parsing empty object ([f56783e](https://github.com/iamkun/dayjs/commit/f56783e14d8cf50916b015e7188b23bb6fbca839)) ## [1.9.1](https://github.com/iamkun/dayjs/compare/v1.9.0...v1.9.1) (2020-09-28) ### Bug Fixes * Fix objectSupport plugin to get the correct result (zero-based month) ([#1089](https://github.com/iamkun/dayjs/issues/1089)) ([f95ac15](https://github.com/iamkun/dayjs/commit/f95ac15a4577ae5a3d1ce353872a2cd9fc454bc2)) # [1.9.0](https://github.com/iamkun/dayjs/compare/v1.8.36...v1.9.0) (2020-09-28) ### Bug Fixes * Add `setDefault` typing to timezone.d.ts ([#1057](https://github.com/iamkun/dayjs/issues/1057)) ([c0f0886](https://github.com/iamkun/dayjs/commit/c0f088620f17260e6e3ebce7697d561b5623f5f3)) * fix DST bug in utc plugin ([#1053](https://github.com/iamkun/dayjs/issues/1053)) ([3d73543](https://github.com/iamkun/dayjs/commit/3d7354361f042ced1176d91f9ae9edffe6173425)) * Fix optional type for timezone plugin ([#1081](https://github.com/iamkun/dayjs/issues/1081)) ([a6ebcf2](https://github.com/iamkun/dayjs/commit/a6ebcf283a83273562dce5663155e3b3a12ea9a5)), closes [#1079](https://github.com/iamkun/dayjs/issues/1079) * Fix timezone plugin conversion bug ([#1073](https://github.com/iamkun/dayjs/issues/1073)) ([16816a3](https://github.com/iamkun/dayjs/commit/16816a31ff43220aca9d1d179df6b729182abb55)) * update duration plugin type file ([#1065](https://github.com/iamkun/dayjs/issues/1065)) ([94af9af](https://github.com/iamkun/dayjs/commit/94af9af27c5bc182cbb24f1845e561dd1d82d776)) * update timezone plugin to support getting offset name e.g. EST ([#1069](https://github.com/iamkun/dayjs/issues/1069)) ([cbb755e](https://github.com/iamkun/dayjs/commit/cbb755e5c68d49c5678291f3ce832b32831a056e)) * update utc plugin to support keepLocalTime `.utc(true)` ([#1080](https://github.com/iamkun/dayjs/issues/1080)) ([5ce4e0d](https://github.com/iamkun/dayjs/commit/5ce4e0d2f552f3645262537ff7afdc946f5a7e72)) ### Features * Correct casing for en-sg locale name ([#1048](https://github.com/iamkun/dayjs/issues/1048)) ([2edaddc](https://github.com/iamkun/dayjs/commit/2edaddc22a7eb914f915531f389766217acd7034)) ## [1.8.36](https://github.com/iamkun/dayjs/compare/v1.8.35...v1.8.36) (2020-09-17) ### Bug Fixes * Add Amharic (am) locale ([#1046](https://github.com/iamkun/dayjs/issues/1046)) ([cdc49a1](https://github.com/iamkun/dayjs/commit/cdc49a1911c74b7ea96ed222f42796d53715cfed)) * Export Duration type in duration plugin ([#1043](https://github.com/iamkun/dayjs/issues/1043)) ([0f20c3a](https://github.com/iamkun/dayjs/commit/0f20c3ac75d9ac1026a15a7bb343d3a150d9b30f)) * Fix duration plugin parsing milliseconds bug ([#1042](https://github.com/iamkun/dayjs/issues/1042)) ([fe2301b](https://github.com/iamkun/dayjs/commit/fe2301b22318886aaa89ed1620e0a118e98c2b8a)) * Timezone plugin set default timezone ([#1033](https://github.com/iamkun/dayjs/issues/1033)) ([0c2050a](https://github.com/iamkun/dayjs/commit/0c2050a152da708b01edd6150a5013f642b14576)) * Timezone plugin should have the same behavior in latest ICU version ([#1032](https://github.com/iamkun/dayjs/issues/1032)) ([de31592](https://github.com/iamkun/dayjs/commit/de315921575cc50c38464b27d0338e30a54d8e2a)) * Update Finnish (fi) locale ([#963](https://github.com/iamkun/dayjs/issues/963)) ([cf8b6a0](https://github.com/iamkun/dayjs/commit/cf8b6a096f24b54cbdb95675ac386d8ac85ea616)) * Update Polish (pl) , Hungarian (hr) and Lithuanian (lt) localization ([#1045](https://github.com/iamkun/dayjs/issues/1045)) ([638fd39](https://github.com/iamkun/dayjs/commit/638fd394fc24f4188390faf387da6b156e7c6320)) ## [1.8.35](https://github.com/iamkun/dayjs/compare/v1.8.34...v1.8.35) (2020-09-02) ### Bug Fixes * Fix BadMutable plugin bug in .diff ([#1023](https://github.com/iamkun/dayjs/issues/1023)) ([40ab6d9](https://github.com/iamkun/dayjs/commit/40ab6d9a53e8047cfca63c611c25dd045372d021)) * fix LocaleData plugin to support instance.weekdays() API ([#1019](https://github.com/iamkun/dayjs/issues/1019)) ([a09d259](https://github.com/iamkun/dayjs/commit/a09d259a407b81d1cb6bb5623fad551c775d8674)), closes [#1017](https://github.com/iamkun/dayjs/issues/1017) * Update Dutch (nl) locale to set correct yearStart ([1533a2c](https://github.com/iamkun/dayjs/commit/1533a2cc1475270032da2d87b19fc3d62327e6e3)) ## [1.8.34](https://github.com/iamkun/dayjs/compare/v1.8.33...v1.8.34) (2020-08-20) ### Bug Fixes * Fix Timezone plugin to preserve milliseconds while changing timezone ([#1003](https://github.com/iamkun/dayjs/issues/1003)) ([5f446ed](https://github.com/iamkun/dayjs/commit/5f446eda770fa97e895c81a8195b3ba5d082cef0)), closes [#1002](https://github.com/iamkun/dayjs/issues/1002) * support parsing unlimited decimals of millisecond ([#1010](https://github.com/iamkun/dayjs/issues/1010)) ([d1bdd36](https://github.com/iamkun/dayjs/commit/d1bdd36a56e3d1786523a180e3fc18068f609135)), closes [#544](https://github.com/iamkun/dayjs/issues/544) * update Duration plugin to support global locale ([#1008](https://github.com/iamkun/dayjs/issues/1008)) ([1c49c83](https://github.com/iamkun/dayjs/commit/1c49c83e79811eede13db6372b5d65db598aee77)), closes [#1007](https://github.com/iamkun/dayjs/issues/1007) ## [1.8.33](https://github.com/iamkun/dayjs/compare/v1.8.32...v1.8.33) (2020-08-10) ### Bug Fixes * Add PluralGetSet plugin for plural getters/setters ([#996](https://github.com/iamkun/dayjs/issues/996)) ([f76e3ce](https://github.com/iamkun/dayjs/commit/f76e3ce2fbe5d3e9ed9121086baf55eb0cc4d355)) * Add typescript type defs in esm build ([#985](https://github.com/iamkun/dayjs/issues/985)) ([50e3b3c](https://github.com/iamkun/dayjs/commit/50e3b3c6719cb0b4ec6eff394dacd63d5db8f253)) * Fix isoWeek Plugin cal bug in UTC mode ([#993](https://github.com/iamkun/dayjs/issues/993)) ([f2e5f32](https://github.com/iamkun/dayjs/commit/f2e5f327aaf12b4572296ec6e107ecc05fcf76e7)) * Fix Timezone plugin parsing js date, Day.js object, timestamp bug && update type file ([#994](https://github.com/iamkun/dayjs/issues/994)) ([22f3d49](https://github.com/iamkun/dayjs/commit/22f3d49405da98db6da56d1673eebcd01b57554b)), closes [#992](https://github.com/iamkun/dayjs/issues/992) [#989](https://github.com/iamkun/dayjs/issues/989) * Fix Timezone plugin UTCOffset rounding bug ([#987](https://github.com/iamkun/dayjs/issues/987)) ([b07182b](https://github.com/iamkun/dayjs/commit/b07182bbdf5aef7f6bf1e88fcd38432e2b8ee465)), closes [#986](https://github.com/iamkun/dayjs/issues/986) * Fix UTC plugin bug while comparing an utc instance to a local one ([#995](https://github.com/iamkun/dayjs/issues/995)) ([747c0fb](https://github.com/iamkun/dayjs/commit/747c0fb4eba6353755b5dad3417fd8d5a408c378)) * Update pt-br locale weekStart 0 ([#984](https://github.com/iamkun/dayjs/issues/984)) ([0f881c1](https://github.com/iamkun/dayjs/commit/0f881c18efb02b9d0ba7f76cba92bb504226fa95)) ## [1.8.32](https://github.com/iamkun/dayjs/compare/v1.8.31...v1.8.32) (2020-08-04) ### Bug Fixes * Add Experimental Timezone Plugin ([#974](https://github.com/iamkun/dayjs/issues/974)) ([e69caba](https://github.com/iamkun/dayjs/commit/e69caba1b0957241a855aa0ae38db899fa2c3795)) * fix parse date string error e.g. '2020/9/30' ([#980](https://github.com/iamkun/dayjs/issues/980)) ([231790d](https://github.com/iamkun/dayjs/commit/231790da62af0494732960c2c50d86ae9bf63ec6)), closes [#979](https://github.com/iamkun/dayjs/issues/979) * update monthDiff function to get more accurate results ([19e8a7f](https://github.com/iamkun/dayjs/commit/19e8a7f2f7582b717f49d446822e39603694433c)) * Update UTC plugin to support keepLocalTime ([#973](https://github.com/iamkun/dayjs/issues/973)) ([9f488e5](https://github.com/iamkun/dayjs/commit/9f488e5aca92f0b4c2951459436829d79f86d8d7)) ## [1.8.31](https://github.com/iamkun/dayjs/compare/v1.8.30...v1.8.31) (2020-07-29) ### Bug Fixes * Rollback LocalePresetType to string ([#968](https://github.com/iamkun/dayjs/issues/968)) ([b342bd3](https://github.com/iamkun/dayjs/commit/b342bd3d84987d6c7587a0c4590d614fb0e670d7)) * Update Regex to parse 'YYYY' correctly ([#969](https://github.com/iamkun/dayjs/issues/969)) ([70c1239](https://github.com/iamkun/dayjs/commit/70c123990dcc6bd479fa2b5d7f9985127872a826)) ## [1.8.30](https://github.com/iamkun/dayjs/compare/v1.8.29...v1.8.30) (2020-07-22) ### Bug Fixes * Add Haitian Creole (ht) and Spanish Puerto Rico (es-pr) locale configs ([#958](https://github.com/iamkun/dayjs/issues/958)) ([b2642e2](https://github.com/iamkun/dayjs/commit/b2642e2d1f87734a34808c66e5176cb18bc0414d)) * Fix UTC plugin wrong hour bug while adding month or year ([#957](https://github.com/iamkun/dayjs/issues/957)) ([28ae070](https://github.com/iamkun/dayjs/commit/28ae070024ff26685c88ce4cc8747307e86923c9)) * Update French (fr) locale to set correct yearStart ([14ab808](https://github.com/iamkun/dayjs/commit/14ab808a7b7e226f2eb2cbe894916a18ed5d967d)), closes [#956](https://github.com/iamkun/dayjs/issues/956) ## [1.8.29](https://github.com/iamkun/dayjs/compare/v1.8.28...v1.8.29) (2020-07-02) ### Bug Fixes * Duration plugin supports parse ISO string with week (W) ([#950](https://github.com/iamkun/dayjs/issues/950)) ([f0fc12a](https://github.com/iamkun/dayjs/commit/f0fc12adadcab53fb0577ad8f5e2f1cf784fd8f5)) * LocaleData plugin supports locale order ([#938](https://github.com/iamkun/dayjs/issues/938)) ([62f429d](https://github.com/iamkun/dayjs/commit/62f429db73a0a069b1267231dea172b85f4b90e3)), closes [#936](https://github.com/iamkun/dayjs/issues/936) * Update type definition to support array format ([#945](https://github.com/iamkun/dayjs/issues/945)) ([81d4740](https://github.com/iamkun/dayjs/commit/81d4740511d47e34f891b21afeb0449ef8a28688)), closes [#944](https://github.com/iamkun/dayjs/issues/944) * Update type definition to support strict mode ([#951](https://github.com/iamkun/dayjs/issues/951)) ([8d54f3f](https://github.com/iamkun/dayjs/commit/8d54f3f7d4d161e72c767fa09699e70a2b3d681c)) ## [1.8.28](https://github.com/iamkun/dayjs/compare/v1.8.27...v1.8.28) (2020-05-28) ### Bug Fixes * Fix CustomParseFormat plugin month index error ([#918](https://github.com/iamkun/dayjs/issues/918)) ([fa2ec7f](https://github.com/iamkun/dayjs/commit/fa2ec7fcb980dcd2c7498dafe2f9ca2e52d735cf)), closes [#915](https://github.com/iamkun/dayjs/issues/915) * Update Ukrainian (uk) locale monthFormat and monthStandalone ([#899](https://github.com/iamkun/dayjs/issues/899)) ([a08756e](https://github.com/iamkun/dayjs/commit/a08756e80bd1d7126fca28c5ad9e382613fc86c4)) ## [1.8.27](https://github.com/iamkun/dayjs/compare/v1.8.26...v1.8.27) (2020-05-14) ### Bug Fixes * Add Kinyarwanda (rw) locale ([#903](https://github.com/iamkun/dayjs/issues/903)) ([f355235](https://github.com/iamkun/dayjs/commit/f355235a836540d77880959fb1b614c87e9f7b3e)) * Add plugin objectSupport ([#887](https://github.com/iamkun/dayjs/issues/887)) ([52dfb13](https://github.com/iamkun/dayjs/commit/52dfb13a6b84f0a753cc5761192b92416f440961)) * Add Turkmen (tk) locale ([#893](https://github.com/iamkun/dayjs/issues/893)) ([a9ca8dc](https://github.com/iamkun/dayjs/commit/a9ca8dcbbd0964c5b9abb4e8a2d620c983cf091a)) * Fix CustomParseFormat plugin set locale error ([#896](https://github.com/iamkun/dayjs/issues/896)) ([8035c8a](https://github.com/iamkun/dayjs/commit/8035c8a760549b631252252718db3cdc4ab2f68f)) * Fix locale month function bug ([#908](https://github.com/iamkun/dayjs/issues/908)) ([bf347c3](https://github.com/iamkun/dayjs/commit/bf347c36e401f50727fb5afcc537497b54b90d6b)) * Update CustomParseFormat plugin to support Array formats ([#906](https://github.com/iamkun/dayjs/issues/906)) ([97856c6](https://github.com/iamkun/dayjs/commit/97856c603ef5fbbeb1cf8a42387479e56a77dbe8)) ## [1.8.26](https://github.com/iamkun/dayjs/compare/v1.8.25...v1.8.26) (2020-04-30) ### Bug Fixes * Fix Duration plugin `.toISOString` format bug ([#889](https://github.com/iamkun/dayjs/issues/889)) ([058d624](https://github.com/iamkun/dayjs/commit/058d624808fd2be024ae846bcb2e03885f39b556)), closes [#888](https://github.com/iamkun/dayjs/issues/888) * Fix WeekOfYear plugin bug while using BadMutable plugin ([#884](https://github.com/iamkun/dayjs/issues/884)) ([2977438](https://github.com/iamkun/dayjs/commit/2977438458542573a4500e21f7ba5d1f8442960e)) * Update CustomParseFormat plugin strict mode ([#882](https://github.com/iamkun/dayjs/issues/882)) ([db642ac](https://github.com/iamkun/dayjs/commit/db642ac73e52e00d8c41546b2935c9e691cf66e0)) * Update RelativeTime plugin default config ([#883](https://github.com/iamkun/dayjs/issues/883)) ([0606f42](https://github.com/iamkun/dayjs/commit/0606f425aef8ccbfc3da3e43cba368130603b0cc)) ## [1.8.25](https://github.com/iamkun/dayjs/compare/v1.8.24...v1.8.25) (2020-04-21) ### Bug Fixes * Fix CustomParseFormat plugin of parsing only YYYY / YYYY-MM bug ([#873](https://github.com/iamkun/dayjs/issues/873)) ([3cea04d](https://github.com/iamkun/dayjs/commit/3cea04d33d54d44bbdd3d026b5c7f67ebf176116)), closes [#849](https://github.com/iamkun/dayjs/issues/849) * Fix Duration plugin get seconds ([#867](https://github.com/iamkun/dayjs/issues/867)) ([62b092d](https://github.com/iamkun/dayjs/commit/62b092d9f9a3db5506ef01f798bdf211f163f53f)) * Fix type definition of locale ([9790b85](https://github.com/iamkun/dayjs/commit/9790b853e6113243a7f4a81dd12c6509e406a102)) * Fix UTC plugin startOf, endOf bug ([#872](https://github.com/iamkun/dayjs/issues/872)) ([4141084](https://github.com/iamkun/dayjs/commit/4141084ba96d35cadcda3f1e661bf1d0f6c8e4de)), closes [#809](https://github.com/iamkun/dayjs/issues/809) [#808](https://github.com/iamkun/dayjs/issues/808) ## [1.8.24](https://github.com/iamkun/dayjs/compare/v1.8.23...v1.8.24) (2020-04-10) ### Bug Fixes * Add config option to RelativeTime plugin ([#851](https://github.com/iamkun/dayjs/issues/851)) ([bd24034](https://github.com/iamkun/dayjs/commit/bd24034b95bfc656024b75ef3f3c986708845fed)) * add Duration plugin ([#858](https://github.com/iamkun/dayjs/issues/858)) ([d568273](https://github.com/iamkun/dayjs/commit/d568273223199ca0497f238e2cc3a8d3dcf32d0f)) * Add en-in, en-tt locales ([#855](https://github.com/iamkun/dayjs/issues/855)) ([c39fb96](https://github.com/iamkun/dayjs/commit/c39fb96e2a9102c14b004c14a6c073af9d266f2f)) * add isToday, isTomorrow, isYesterday plugins ([#857](https://github.com/iamkun/dayjs/issues/857)) ([fc08ab6](https://github.com/iamkun/dayjs/commit/fc08ab68f8a28269802deeab9d6b0473b92cdc51)) * Add option callback to Calendar plugin ([#839](https://github.com/iamkun/dayjs/issues/839)) ([b25be90](https://github.com/iamkun/dayjs/commit/b25be9094325295310c8fc5e617fb058be8a5f68)) * Fix monthsShort for locale fr ([#862](https://github.com/iamkun/dayjs/issues/862)) ([d2de9a0](https://github.com/iamkun/dayjs/commit/d2de9a0b44b830038ed0094f79bfd40726311f2a)) * Update Breton locale (br) meridiem config ([#856](https://github.com/iamkun/dayjs/issues/856)) ([a2a6672](https://github.com/iamkun/dayjs/commit/a2a66720abb788a8f1cffbfd0929b35579f29c72)) * Update Ukrainian (uk) locale relative time ([#842](https://github.com/iamkun/dayjs/issues/842)) ([578bc1a](https://github.com/iamkun/dayjs/commit/578bc1a23c6e737783bbac3da12c0ed5d1edcf82)) ## [1.8.23](https://github.com/iamkun/dayjs/compare/v1.8.22...v1.8.23) (2020-03-16) ### Bug Fixes * Add Chinese (zh) locale ([f9b8945](https://github.com/iamkun/dayjs/commit/f9b89453166d8b53d33b1d7eefd9942022552e6e)) * Fix IsoWeek plugin typescript definition ([#828](https://github.com/iamkun/dayjs/issues/828)) ([30aab0c](https://github.com/iamkun/dayjs/commit/30aab0c7bce85dfac0ae208a891def30f88b5cb4)) * Update Arabic (ar) locale relative time ([#836](https://github.com/iamkun/dayjs/issues/836)) ([14044c6](https://github.com/iamkun/dayjs/commit/14044c6fda1229e3f0e5473d3f886bd79589b15f)) * Update Slovak (sk) locale, Czech (cs) locale ([#833](https://github.com/iamkun/dayjs/issues/833)) ([f0d451f](https://github.com/iamkun/dayjs/commit/f0d451f795e9ebf752cd854d51b25b11de2343a3)) * Update Thai (th) locale relativeTime ([#826](https://github.com/iamkun/dayjs/issues/826)) ([63b7c03](https://github.com/iamkun/dayjs/commit/63b7c03a6dbb0507d60776e8bad6cccde3828b88)), closes [#816](https://github.com/iamkun/dayjs/issues/816) ## [1.8.22](https://github.com/iamkun/dayjs/compare/v1.8.21...v1.8.22) (2020-03-08) ### Bug Fixes * Add IsoWeek plugin ([#811](https://github.com/iamkun/dayjs/issues/811)) ([28a2207](https://github.com/iamkun/dayjs/commit/28a2207ef9849afbac15dd29267b2e7a09cd3c16)) * Fix unsupported locale fallback to previous one ([#819](https://github.com/iamkun/dayjs/issues/819)) ([4868715](https://github.com/iamkun/dayjs/commit/48687152cf5bee6a4c1b8ceea4bda8b9bab9be10)) ## [1.8.21](https://github.com/iamkun/dayjs/compare/v1.8.20...v1.8.21) (2020-02-26) ### Bug Fixes * Set + Get accept 'D' as the short version of 'date' ([#795](https://github.com/iamkun/dayjs/issues/795)) ([523c038](https://github.com/iamkun/dayjs/commit/523c03880fa8bbad83214494ad02cd606cdb8b30)) * Update DayOfYear plugin type ([#799](https://github.com/iamkun/dayjs/issues/799)) ([5809652](https://github.com/iamkun/dayjs/commit/5809652e40245b7759827d9bf317abdcfa75a330)) * Update fi (Finnish) locale relativeTime ([#797](https://github.com/iamkun/dayjs/issues/797)) ([4a470fb](https://github.com/iamkun/dayjs/commit/4a470fbd6fef9e051727d0f26d53cc050b85935d)) ## [1.8.20](https://github.com/iamkun/dayjs/compare/v1.8.19...v1.8.20) (2020-02-04) ### Bug Fixes * Add Bislama Locale (bi) ([#780](https://github.com/iamkun/dayjs/issues/780)) ([9ac6ab4](https://github.com/iamkun/dayjs/commit/9ac6ab481bc883dd4ecc02caab12c8b2fc218a42)) * Fix weekOfYear plugin to support yearStart locale for better week number result ([#769](https://github.com/iamkun/dayjs/issues/769)) ([f00db36](https://github.com/iamkun/dayjs/commit/f00db36e70bc7beaca1abadeb30a9b1fbb3261ee)) * Update et (Estonian) locale relativeTime ([#790](https://github.com/iamkun/dayjs/issues/790)) ([d8e0f45](https://github.com/iamkun/dayjs/commit/d8e0f45f6cd2d5e5704b9797929227454c92d1a5)) * Update LocaleData plugin to support dayjs.localeData().weekdays() API ([287fed6](https://github.com/iamkun/dayjs/commit/287fed6db9eb4fd979b4861aca4dacbd32422533)), closes [#779](https://github.com/iamkun/dayjs/issues/779) * Update LocaleData plugin to support dayjs.months dayjs.weekdays API ([144c2ae](https://github.com/iamkun/dayjs/commit/144c2ae6e15fbf89e3acd7c8cb9e237c5f6e1348)), closes [#779](https://github.com/iamkun/dayjs/issues/779) * Update pl locale fusional config ([d372475](https://github.com/iamkun/dayjs/commit/d3724758bb27d5b17587b995ba14e7e80dcd1151)) ## [1.8.19](https://github.com/iamkun/dayjs/compare/v1.8.18...v1.8.19) (2020-01-06) ### Bug Fixes * Add UpdateLocale plugin to update a locale's properties ([#766](https://github.com/iamkun/dayjs/issues/766)) ([82ce2ba](https://github.com/iamkun/dayjs/commit/82ce2ba8d7e402e40f6d005d400eb5356a0b0633)) * Fix CustomParseFormat Plugin 'YYYY-MM' use first day of the month ([ba709ec](https://github.com/iamkun/dayjs/commit/ba709eca86a71ae648bc68bf67d9abdc229198d4)), closes [#761](https://github.com/iamkun/dayjs/issues/761) * Fix CustomParseFormat Plugin to set correct locale ([66ce23f](https://github.com/iamkun/dayjs/commit/66ce23f2e18c5506e8f1a7ef20d3483a4df80087)) * Fix WeekOfYear Plugin wrong calender week number bug ([79b86db](https://github.com/iamkun/dayjs/commit/79b86dbbf3cfd3f1e2165b3d479a7061ad1b6925)), closes [#760](https://github.com/iamkun/dayjs/issues/760) * Update RelativeTime plugin to support function to make additional processing ([#767](https://github.com/iamkun/dayjs/issues/767)) ([4bd9250](https://github.com/iamkun/dayjs/commit/4bd9250fbe7131e2fddfb5fa1b3350e8c2262ca9)) * Update ru, uk, cs locale to support relativeTime with plural ([3f080f7](https://github.com/iamkun/dayjs/commit/3f080f7d6bfdc4018cbb7c4d0112ff1ead4ef6b8)) ## [1.8.18](https://github.com/iamkun/dayjs/compare/v1.8.17...v1.8.18) (2019-12-18) ### Bug Fixes * Add missing locale type definition ([#716](https://github.com/iamkun/dayjs/issues/716)) ([cde5d0b](https://github.com/iamkun/dayjs/commit/cde5d0b91be7b2f5f3098de4aa0b9a4f0f28ea5c)) * Fix .locale() handel unsupported locale ([78ec173](https://github.com/iamkun/dayjs/commit/78ec173fcecc1299516ab7b44f4554d431b4b2fd)) * Update Italian locale (it) ([#727](https://github.com/iamkun/dayjs/issues/727)) ([5b53e98](https://github.com/iamkun/dayjs/commit/5b53e98c0a3ba0eb9573a9c77caeb907439be9e7)) * Update locale (fa) ([#733](https://github.com/iamkun/dayjs/issues/733)) ([9ad2e47](https://github.com/iamkun/dayjs/commit/9ad2e47e0569b23991bb0d5578f49c792c12df08)) * Update locale (zh-cn) ([#706](https://github.com/iamkun/dayjs/issues/706)) ([e31e544](https://github.com/iamkun/dayjs/commit/e31e54414fb90e1f54da13a117748ba37f52645d)) * Update locale (zh-cn) meridiem ([#735](https://github.com/iamkun/dayjs/issues/735)) ([15d1b81](https://github.com/iamkun/dayjs/commit/15d1b813e7faf5a1f9d1ea6fc673fd27ac49d8b1)) * Update LocaleData plugin to support dayjs().longDateFormat() ([#734](https://github.com/iamkun/dayjs/issues/734)) ([aa0f210](https://github.com/iamkun/dayjs/commit/aa0f210a1e3c4f6aba61c3b96f9eb445b43a33f0)), closes [#680](https://github.com/iamkun/dayjs/issues/680) * Update Mongolian (mn) locale relativeTime ([#753](https://github.com/iamkun/dayjs/issues/753)) ([6d51435](https://github.com/iamkun/dayjs/commit/6d51435092c0c94d8e50256d3f0f058cdd15febe)) * Update Swedish locale (sv) fix ordinal error ([#745](https://github.com/iamkun/dayjs/issues/745)) ([49670d5](https://github.com/iamkun/dayjs/commit/49670d5ae31e4e21636cc5a8bfe35fef0f6d9e4a)), closes [#743](https://github.com/iamkun/dayjs/issues/743) ## [1.8.17](https://github.com/iamkun/dayjs/compare/v1.8.16...v1.8.17) (2019-11-06) ### Bug Fixes * Fix set utcOffset in utc mode ([d148115](https://github.com/iamkun/dayjs/commit/d148115dad8f1a5afc0a64e9b8163dfeba4616b6)) * Update advancedFormat plugin to support w ww wo week tokens … ([#678](https://github.com/iamkun/dayjs/issues/678)) ([26cfa63](https://github.com/iamkun/dayjs/commit/26cfa63a524b803f7966dac5464f9cbf8f63387e)), closes [#676](https://github.com/iamkun/dayjs/issues/676) * Update ka locale weekdays ([f8ca3d4](https://github.com/iamkun/dayjs/commit/f8ca3d4ba1d3cbe41613d3909c0627935a51a0c4)) * Update nb locale ([#679](https://github.com/iamkun/dayjs/issues/679)) ([1063b0e](https://github.com/iamkun/dayjs/commit/1063b0e1b5c19a1354d233cc0f21438e7073233a)) * Update Polish locale (pl)([#713](https://github.com/iamkun/dayjs/issues/713)) ([30d2f02](https://github.com/iamkun/dayjs/commit/30d2f026b47188833a4f44fee4bab52467d4a718)) * Update Ukrainian locale (uk) ([#710](https://github.com/iamkun/dayjs/issues/710)) ([360161c](https://github.com/iamkun/dayjs/commit/360161cac75f597fdd51d9d1ff138601282a1b4b)) * UTC plugin set utcOffset value ([#668](https://github.com/iamkun/dayjs/issues/668)) ([8877883](https://github.com/iamkun/dayjs/commit/88778838e71dd309e79cd1a8094d5bea36ca3390)) ## [1.8.16](https://github.com/iamkun/dayjs/compare/v1.8.15...v1.8.16) (2019-08-27) ### Bug Fixes * Fix relativeTime Plugin .FromNow() result error in UTC mode ([a385d5c](https://github.com/iamkun/dayjs/commit/a385d5c)) * Handle locale in WeekOfYear plugin ([#658](https://github.com/iamkun/dayjs/issues/658)) ([0e45b0a](https://github.com/iamkun/dayjs/commit/0e45b0a)) * LocaleData plugin returns all months and weekdays data when pas no argument ([#645](https://github.com/iamkun/dayjs/issues/645)) ([95e70b4](https://github.com/iamkun/dayjs/commit/95e70b4)) * Return null in toJSON if not valid ([#633](https://github.com/iamkun/dayjs/issues/633)) ([19affc8](https://github.com/iamkun/dayjs/commit/19affc8)) * Update Danish (da) locale ([#626](https://github.com/iamkun/dayjs/issues/626)) ([ac2ec77](https://github.com/iamkun/dayjs/commit/ac2ec77)) * Update Korean locale meridiem ([#642](https://github.com/iamkun/dayjs/issues/642)) ([b457146](https://github.com/iamkun/dayjs/commit/b457146)) * update Occitan locale Catalan locale ([#630](https://github.com/iamkun/dayjs/issues/630)) ([fef135e](https://github.com/iamkun/dayjs/commit/fef135e)) * update pt-br locale ([#628](https://github.com/iamkun/dayjs/issues/628)) ([ccf596d](https://github.com/iamkun/dayjs/commit/ccf596d)) * Update weekdaysShort to some locale files ([#643](https://github.com/iamkun/dayjs/issues/643)) ([cc1f15f](https://github.com/iamkun/dayjs/commit/cc1f15f)) ## [1.8.15](https://github.com/iamkun/dayjs/compare/v1.8.14...v1.8.15) (2019-07-08) ### Bug Fixes * Fix dayjs.locale() returns current global locale ([#602](https://github.com/iamkun/dayjs/issues/602)) ([790cd1a](https://github.com/iamkun/dayjs/commit/790cd1a)) * Fix incorrect Thai locale translation of July ([#607](https://github.com/iamkun/dayjs/issues/607)) ([43cbfd3](https://github.com/iamkun/dayjs/commit/43cbfd3)) * Lowercase french locale months and weekdays ([#615](https://github.com/iamkun/dayjs/issues/615)) ([e5a257c](https://github.com/iamkun/dayjs/commit/e5a257c)) * Type - Export Ls object to query all available locales ([#623](https://github.com/iamkun/dayjs/issues/623)) ([f6bfae0](https://github.com/iamkun/dayjs/commit/f6bfae0)) * Update nb (Norsk Bokmål) locale ([#604](https://github.com/iamkun/dayjs/issues/604)) ([907f5c9](https://github.com/iamkun/dayjs/commit/907f5c9)) * Update types of `.diff` API ([#617](https://github.com/iamkun/dayjs/issues/617)) ([f0f43d2](https://github.com/iamkun/dayjs/commit/f0f43d2)) ## [1.8.14](https://github.com/iamkun/dayjs/compare/v1.8.13...v1.8.14) (2019-05-07) ### Bug Fixes * Fix `.format` API returns UTC offset when value is 0 bug ([b254964](https://github.com/iamkun/dayjs/commit/b254964)) * Fix QuarterOfYear plugin bug ([#591](https://github.com/iamkun/dayjs/issues/591)) ([434f774](https://github.com/iamkun/dayjs/commit/434f774)) * Fix UTC plugin add day DST bug ([#590](https://github.com/iamkun/dayjs/issues/590)) ([86cd839](https://github.com/iamkun/dayjs/commit/86cd839)) ## [1.8.13](https://github.com/iamkun/dayjs/compare/v1.8.12...v1.8.13) (2019-04-26) ### Bug Fixes * Add missing relativeTime and formats for some locales ([#560](https://github.com/iamkun/dayjs/issues/560)) ([96b917e](https://github.com/iamkun/dayjs/commit/96b917e)) * Add weekday (locale aware day of the week) plugin ([#569](https://github.com/iamkun/dayjs/issues/569)) ([9007cc5](https://github.com/iamkun/dayjs/commit/9007cc5)), closes [#559](https://github.com/iamkun/dayjs/issues/559) * Allow customizing "am" / "pm" strings with locale meridiem function ([#580](https://github.com/iamkun/dayjs/issues/580)) ([576e93e](https://github.com/iamkun/dayjs/commit/576e93e)), closes [#578](https://github.com/iamkun/dayjs/issues/578) * Fix `.add` day/week decimal rouding bug ([800f6c9](https://github.com/iamkun/dayjs/commit/800f6c9)) * Fix `.diff` type definition error ([#565](https://github.com/iamkun/dayjs/issues/565)) ([c4921ae](https://github.com/iamkun/dayjs/commit/c4921ae)), closes [#561](https://github.com/iamkun/dayjs/issues/561) * Fix CustomParseFormat plugin bug ([#568](https://github.com/iamkun/dayjs/issues/568)) ([1f5a9db](https://github.com/iamkun/dayjs/commit/1f5a9db)), closes [#555](https://github.com/iamkun/dayjs/issues/555) * Fix relativeTime plugin Math.round bug ([40bea40](https://github.com/iamkun/dayjs/commit/40bea40)) * skip square brackets in buddhistEra, advancedFormat plugins ([#556](https://github.com/iamkun/dayjs/issues/556)) ([9279718](https://github.com/iamkun/dayjs/commit/9279718)), closes [#554](https://github.com/iamkun/dayjs/issues/554) * Update Indonesian locale([#574](https://github.com/iamkun/dayjs/issues/574)) ([0aa7143](https://github.com/iamkun/dayjs/commit/0aa7143)) * Update locale month to support both array and function ([#581](https://github.com/iamkun/dayjs/issues/581)) ([b6599d3](https://github.com/iamkun/dayjs/commit/b6599d3)) * Update LocalizedFormat plugin lowercase formats logic ([#557](https://github.com/iamkun/dayjs/issues/557)) ([d409304](https://github.com/iamkun/dayjs/commit/d409304)) ## [1.8.12](https://github.com/iamkun/dayjs/compare/v1.8.11...v1.8.12) (2019-04-02) ### Bug Fixes * Add .get API ([7318797](https://github.com/iamkun/dayjs/commit/7318797)) * Add 79 locales ([#541](https://github.com/iamkun/dayjs/issues/541)) ([f75a125](https://github.com/iamkun/dayjs/commit/f75a125)) * Add Calendar plugin ([d1b9cf9](https://github.com/iamkun/dayjs/commit/d1b9cf9)) * Add isoWeeksInYear plugin ([2db8631](https://github.com/iamkun/dayjs/commit/2db8631)) * Add Occitan (oc-lnc) locale file ([#551](https://github.com/iamkun/dayjs/issues/551)) ([c30b715](https://github.com/iamkun/dayjs/commit/c30b715)) * Add plugin minMax to sopport .max .min ([2870a23](https://github.com/iamkun/dayjs/commit/2870a23)) * Fix set Month Year error in last day of the month ([d058f4a](https://github.com/iamkun/dayjs/commit/d058f4a)) * Update ko locale weekdaysShort ([#543](https://github.com/iamkun/dayjs/issues/543)) ([317fd3e](https://github.com/iamkun/dayjs/commit/317fd3e)) * Update localizedFormat plugin to support lowercase localizable formats (l, ll, lll, llll) ([#546](https://github.com/iamkun/dayjs/issues/546)) ([f2b5ebf](https://github.com/iamkun/dayjs/commit/f2b5ebf)) ## [1.8.11](https://github.com/iamkun/dayjs/compare/v1.8.10...v1.8.11) (2019-03-21) ### Bug Fixes * Add .add('quarter') .startOf('quarter') through plugin quarterOfYear ([dde39e9](https://github.com/iamkun/dayjs/commit/dde39e9)), closes [#537](https://github.com/iamkun/dayjs/issues/537) [#531](https://github.com/iamkun/dayjs/issues/531) * Add locale support for Azerbaijani language (az) ([#535](https://github.com/iamkun/dayjs/issues/535)) ([eeb20fa](https://github.com/iamkun/dayjs/commit/eeb20fa)) * Correct typescript definition `add` ([22a249c](https://github.com/iamkun/dayjs/commit/22a249c)), closes [#531](https://github.com/iamkun/dayjs/issues/531) * Fix CustomParseFormat plugin formatting bug ([#536](https://github.com/iamkun/dayjs/issues/536)) ([8578546](https://github.com/iamkun/dayjs/commit/8578546)), closes [#533](https://github.com/iamkun/dayjs/issues/533) * Update pt locale ([#538](https://github.com/iamkun/dayjs/issues/538)) ([1ac9e1e](https://github.com/iamkun/dayjs/commit/1ac9e1e)) ## [1.8.10](https://github.com/iamkun/dayjs/compare/v1.8.9...v1.8.10) (2019-03-10) ### Bug Fixes * **locale:** Add nepali (ne) locale ([#524](https://github.com/iamkun/dayjs/issues/524)) ([bdbec01](https://github.com/iamkun/dayjs/commit/bdbec01)) * Add WeekYear plugin ([a892608](https://github.com/iamkun/dayjs/commit/a892608)) * API .locale() with no argument should return current locale name string ([8d63d88](https://github.com/iamkun/dayjs/commit/8d63d88)) * CustomParseFormat correct parse HH:mm:ss with only one digit like 0:12:10 ([600d547](https://github.com/iamkun/dayjs/commit/600d547)) * CustomParseFormat plugin parse Do format string ([bf27fda](https://github.com/iamkun/dayjs/commit/bf27fda)), closes [#522](https://github.com/iamkun/dayjs/issues/522) * Expand setters like .year(2000) .hour(12) ([ac532a0](https://github.com/iamkun/dayjs/commit/ac532a0)) * Move toObject, toArray API to separate plugin from core ([40a3431](https://github.com/iamkun/dayjs/commit/40a3431)) ## [1.8.9](https://github.com/iamkun/dayjs/compare/v1.8.8...v1.8.9) (2019-03-06) ### Features * Add UTC mode with UTC plugin ([#517](https://github.com/iamkun/dayjs/issues/517)) ([caf335c](https://github.com/iamkun/dayjs/commit/caf335c)) > For plugin developers: Please note, we have changed the name of some method in `Utils` in order to reduce the file size. ([#517](https://github.com/iamkun/dayjs/issues/517)) ([detail](https://github.com/iamkun/dayjs/pull/517/files#diff-2b4ca49d4bb0a774c4d4c1672d7aa781R46)) ### Bug Fixes * Add locale de-AT ([#515](https://github.com/iamkun/dayjs/issues/515)) ([d93f7b6](https://github.com/iamkun/dayjs/commit/d93f7b6)) * Add locale zh-hk ([#516](https://github.com/iamkun/dayjs/issues/516)) ([5fc05a6](https://github.com/iamkun/dayjs/commit/5fc05a6)) ## [1.8.8](https://github.com/iamkun/dayjs/compare/v1.8.7...v1.8.8) (2019-02-25) ### Bug Fixes * Update relativeTime plugin type definition ([de56f2c](https://github.com/iamkun/dayjs/commit/de56f2c)) ## [1.8.7](https://github.com/iamkun/dayjs/compare/v1.8.6...v1.8.7) (2019-02-24) ### Bug Fixes * Add plugin type definitions ([#418](https://github.com/iamkun/dayjs/issues/418)) ([361d437](https://github.com/iamkun/dayjs/commit/361d437)) * Add Swahili locale ([#508](https://github.com/iamkun/dayjs/issues/508)) ([b9cee84](https://github.com/iamkun/dayjs/commit/b9cee84)) * Parse month string 'MMMM MMM (February, Feb)' in customParseFormat ([#457](https://github.com/iamkun/dayjs/issues/457)) ([f343206](https://github.com/iamkun/dayjs/commit/f343206)) * Update declaration file .diff .isBefore .isSame .isAfter ([#496](https://github.com/iamkun/dayjs/issues/496)) ([4523275](https://github.com/iamkun/dayjs/commit/4523275)) * Word orders corrections for locale 'fa' ([#491](https://github.com/iamkun/dayjs/issues/491)) ([56050c2](https://github.com/iamkun/dayjs/commit/56050c2)) ## [1.8.6](https://github.com/iamkun/dayjs/compare/v1.8.5...v1.8.6) (2019-02-14) ### Bug Fixes * Add Bahasa Melayu (Malaysia) locale ([#485](https://github.com/iamkun/dayjs/issues/485)) ([cb208b0](https://github.com/iamkun/dayjs/commit/cb208b0)) * Copy & export built-in en locale to /locale folder as a separate file ([a7e05e0](https://github.com/iamkun/dayjs/commit/a7e05e0)) * Fix bug in customParseFormat plugin while month(MM) is '01' ([9884ca5](https://github.com/iamkun/dayjs/commit/9884ca5)), closes [#494](https://github.com/iamkun/dayjs/issues/494) * Fix startOf week bug while week start is not Sunday ([5eaf77b](https://github.com/iamkun/dayjs/commit/5eaf77b)) * Implemented isBetween inclusivity ([#464](https://github.com/iamkun/dayjs/issues/464)) ([af2f4f1](https://github.com/iamkun/dayjs/commit/af2f4f1)) * Update Swedish and Finnish locales ([#488](https://github.com/iamkun/dayjs/issues/488)) ([f142082](https://github.com/iamkun/dayjs/commit/f142082)) * Fix commonJS require ES Module bug in webpack4 ([23f9f3d](https://github.com/iamkun/dayjs/commit/23f9f3d)), check [#492](https://github.com/iamkun/dayjs/issues/492) > Get access to ESM code with `import dayjs from 'dayjs/esm'` ## [1.8.5](https://github.com/iamkun/dayjs/compare/v1.8.4...v1.8.5) (2019-02-07) ### Bug Fixes * Add en-gb locale ([#478](https://github.com/iamkun/dayjs/issues/478)) ([508c3a7](https://github.com/iamkun/dayjs/commit/508c3a7)) * **module:** transpile everything except ES6 modules in the 'module' entrypoint ([#477](https://github.com/iamkun/dayjs/issues/477)) ([#480](https://github.com/iamkun/dayjs/issues/480)) ([#482](https://github.com/iamkun/dayjs/issues/482)) ([767017d](https://github.com/iamkun/dayjs/commit/767017d)) * update customParseFormat plugin support hh:mm ([54947cc](https://github.com/iamkun/dayjs/commit/54947cc)), closes [#484](https://github.com/iamkun/dayjs/issues/484) * Update module in package.json ([5c5a7a0](https://github.com/iamkun/dayjs/commit/5c5a7a0)) ## [1.8.4](https://github.com/iamkun/dayjs/compare/v1.8.3...v1.8.4) (2019-02-05) * Allow set start day of week in locale && Allow set week in weekOfYear plugin ([1295591](https://github.com/iamkun/dayjs/commit/1295591)) ### Bug Fixes * update all locale files with correct week start ([5b03412](https://github.com/iamkun/dayjs/commit/5b03412)) * update es es-do locale adding weekStart && update weekStart test ([66e42ec](https://github.com/iamkun/dayjs/commit/66e42ec)) * Revert default export ([b00da1b](https://github.com/iamkun/dayjs/commit/b00da1b)) ## [1.8.3](https://github.com/iamkun/dayjs/compare/v1.8.2...v1.8.3) (2019-02-04) ### Bug Fixes * fix ios safari YYYY-MM-DD HH:mm parse BUG ([e02ae82](https://github.com/iamkun/dayjs/commit/e02ae82)), closes [#254](https://github.com/iamkun/dayjs/issues/254) ## [1.8.2](https://github.com/iamkun/dayjs/compare/v1.8.1...v1.8.2) (2019-02-02) ### Bug Fixes * Add missing czech language locale ([#461](https://github.com/iamkun/dayjs/issues/461)) ([7e04004](https://github.com/iamkun/dayjs/commit/7e04004)) * Add utcOffset api method and fix calculating diff error in DST ([#453](https://github.com/iamkun/dayjs/issues/453)) ([ce2e30e](https://github.com/iamkun/dayjs/commit/ce2e30e)) * Fix it locale error ([#458](https://github.com/iamkun/dayjs/issues/458)) ([f6d9a64](https://github.com/iamkun/dayjs/commit/f6d9a64)) * Add DayOfYear plugin (#454) * Fix es locale monthsShort error ## [1.8.1](https://github.com/iamkun/dayjs/compare/v1.8.0...v1.8.1) (2019-02-02) * Add LocalizedFormat plugin supplying format like LTS, LT, LLLL * update declaration File with default export (#278) > From v1.8.1, in TypeScript Project, just `import from dayjs from 'dayjs'` * add ES2015 module support (#451) ### Performance Improvements * **format:** reuse matches instead of created when replacing ([#441](https://github.com/iamkun/dayjs/issues/441)) ([10b79d8](https://github.com/iamkun/dayjs/commit/10b79d8)) # [1.8.0](https://github.com/iamkun/dayjs/compare/v1.7.8...v1.8.0) (2019-01-14) ### Features * add CustomParseFormat plugin and QuarterOfYear plugin ([#450](https://github.com/iamkun/dayjs/issues/450)) ([8f6f63c](https://github.com/iamkun/dayjs/commit/8f6f63c)) ## [1.7.8](https://github.com/iamkun/dayjs/compare/v1.7.7...v1.7.8) (2018-12-13) ### Feature * update isSame isBefore isAfter supports units ([fd65464](https://github.com/iamkun/dayjs/commit/fd65464)) * add greek lithuanian locales ## [1.7.7](https://github.com/iamkun/dayjs/compare/v1.7.6...v1.7.7) (2018-09-26) ### Bug Fixes * **DST:** fix daylight saving time DST bug && add test ([#354](https://github.com/iamkun/dayjs/issues/354)) ([6fca6d5](https://github.com/iamkun/dayjs/commit/6fca6d5)) ## [1.7.6](https://github.com/iamkun/dayjs/compare/v1.7.5...v1.7.6) (2018-09-25) ### Bug Fixes * **add dayjs.unix:** add dayjs.unix to parse timestamp in seconds && locale update ([5711c5e](https://github.com/iamkun/dayjs/commit/5711c5e)) ## [1.7.5](https://github.com/iamkun/dayjs/compare/v1.7.4...v1.7.5) (2018-08-10) ### Bug Fixes * add isBetween API & update ([b5fc3d1](https://github.com/iamkun/dayjs/commit/b5fc3d1)) ## [1.7.4](https://github.com/iamkun/dayjs/compare/v1.7.3...v1.7.4) (2018-07-11) ### Bug Fixes * update set week logic ([60b6325](https://github.com/iamkun/dayjs/commit/60b6325)), closes [#276](https://github.com/iamkun/dayjs/issues/276) ## [1.7.3](https://github.com/iamkun/dayjs/compare/v1.7.2...v1.7.3) (2018-07-10) ### Bug Fixes * **locale-nl:** set correct weekdays and months ([6d089d7](https://github.com/iamkun/dayjs/commit/6d089d7)) ## [1.7.2](https://github.com/iamkun/dayjs/compare/v1.7.1...v1.7.2) (2018-07-04) ### Bug Fixes * DEPRECATED isLeapYear, use IsLeapYear plugin instead ([e2e5116](https://github.com/iamkun/dayjs/commit/e2e5116)) ## [1.7.1](https://github.com/iamkun/dayjs/compare/v1.7.0...v1.7.1) (2018-07-03) ### Bug Fixes * fix week() error near the end of the year ([fa03689](https://github.com/iamkun/dayjs/commit/fa03689)) # [1.7.0](https://github.com/iamkun/dayjs/compare/v1.6.10...v1.7.0) (2018-07-02) ### Features * Added method `.week()` to retrieve week of the year ([e1c1b1c](https://github.com/iamkun/dayjs/commit/e1c1b1c)) * Updated Japanese locae ## [1.6.10](https://github.com/iamkun/dayjs/compare/v1.6.9...v1.6.10) (2018-06-25) ### Bug Fixes * Add relative locales to russian language ([c7e9898](https://github.com/iamkun/dayjs/commit/c7e9898)), closes [#256](https://github.com/iamkun/dayjs/issues/256) ## [1.6.9](https://github.com/iamkun/dayjs/compare/v1.6.8...v1.6.9) (2018-06-14) ### Bug Fixes * add isDayjs => boolean API ([6227c8b](https://github.com/iamkun/dayjs/commit/6227c8b)) ## [1.6.8](https://github.com/iamkun/dayjs/compare/v1.6.7...v1.6.8) (2018-06-14) ### Bug Fixes * fix Advanced format bug in zh-cn ([0c07874](https://github.com/iamkun/dayjs/commit/0c07874)), closes [#242](https://github.com/iamkun/dayjs/issues/242) ## [1.6.7](https://github.com/iamkun/dayjs/compare/v1.6.6...v1.6.7) (2018-06-11) ### Bug Fixes * fix id locale ([1ebbeb8](https://github.com/iamkun/dayjs/commit/1ebbeb8)), closes [#234](https://github.com/iamkun/dayjs/issues/234) ## [1.6.6](https://github.com/iamkun/dayjs/compare/v1.6.5...v1.6.6) (2018-06-06) ### Bug Fixes * format API update and locale file update ([5ca48f0](https://github.com/iamkun/dayjs/commit/5ca48f0)), closes [#228](https://github.com/iamkun/dayjs/issues/228) ## [1.6.5](https://github.com/iamkun/dayjs/compare/v1.6.4...v1.6.5) (2018-05-31) ### Bug Fixes * bugfix, utils update and locale file update ([ebcb6d5](https://github.com/iamkun/dayjs/commit/ebcb6d5)), closes [#214](https://github.com/iamkun/dayjs/issues/214) ## [1.6.4](https://github.com/iamkun/dayjs/compare/v1.6.3...v1.6.4) (2018-05-25) ### Bug Fixes * add RelativeTime plugin and locale file update ([c1fbbca](https://github.com/iamkun/dayjs/commit/c1fbbca)), closes [#198](https://github.com/iamkun/dayjs/issues/198) ## [1.6.3](https://github.com/iamkun/dayjs/compare/v1.6.2...v1.6.3) (2018-05-21) ### Bug Fixes * Changing locales locally is immutable from this release ([2cce729](https://github.com/iamkun/dayjs/commit/2cce729)), closes [#182](https://github.com/iamkun/dayjs/issues/182) * instance locale change should be immutable ([84597c9](https://github.com/iamkun/dayjs/commit/84597c9)) * Add more locales * english ordinal fix ## [1.6.2](https://github.com/iamkun/dayjs/compare/v1.6.1...v1.6.2) (2018-05-18) ### Bug Fixes * change-log update && test new npm release ([aa49cba](https://github.com/iamkun/dayjs/commit/aa49cba)), closes [#163](https://github.com/iamkun/dayjs/issues/163) ## [1.6.1](https://github.com/iamkun/dayjs/compare/v1.6.0...v1.6.1) (2018-05-18) ### Bug Fixes * Add German, Brazilian Portuguese locales * add() & parse() bug fix & add locale de, pt-br ([bf1331e](https://github.com/iamkun/dayjs/commit/bf1331e)) # [1.6.0](https://github.com/iamkun/dayjs/compare/v1.5.24...v1.6.0) (2018-05-15) ### Features * Locale && Plugin ([2342c55](https://github.com/iamkun/dayjs/commit/2342c55)), closes [#141](https://github.com/iamkun/dayjs/issues/141) ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing to Day.js Thank you for taking the time to read our contribution guidelines. You can start contributing in many ways like filing bug reports, [improving the locale && documentation](https://github.com/iamkun/dayjs/issues/171), or helping others. Our open source community strives to be nice, welcoming and professional. Instances of abusive, harassing, or otherwise unacceptable behavior will not be tolerated. ## Style * Day.js is written in ES6. * We use ESLint to check our code. You can use `npm run lint` before submitting a pull request. * Please use semantic commit message. ## Bugs * Before submitting a bug report, search the issues for similar tickets. Your issue may have already been discussed and resolved. * Feel free to add a comment to an existing issue, even if it's closed. * Be thorough in your title and report, don't leave out important details. * English, please. ## Tests * Feel free to create a new `test/*.test.js` file if none of the existing test files suits your test case. * Help us keeping 100% test coverage :D. * You can use `npm run test` before submitting a pull request. ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2018-present, iamkun Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md) | [සිංහල](./docs/si/README-si.md) | [עברית](./docs/he/README-he.md)

Day.js

Fast 2kB alternative to Moment.js with the same modern API

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js. ```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` * 🕒 Familiar Moment.js API & patterns * 💪 Immutable * 🔥 Chainable * 🌐 I18n support * 📦 2kb mini library * 👫 All browsers supported --- ## Getting Started ### Documentation You can find more details, API, and other docs on [day.js.org](https://day.js.org/) website. ### Installation ```console npm install dayjs --save ``` 📚[Installation Guide](https://day.js.org/docs/en/installation/installation) ### API It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times. ```javascript dayjs('2018-08-08') // parse dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display dayjs().set('month', 3).month() // get & set dayjs().add(1, 'year') // manipulate dayjs().isBefore(dayjs()) // query ``` 📚[API Reference](https://day.js.org/docs/en/parse/parse) ### I18n Day.js has great support for internationalization. But none of them will be included in your build unless you use it. ```javascript import 'dayjs/locale/es' // load on demand dayjs.locale('es') // use Spanish locale globally dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance ``` 📚[Internationalization](https://day.js.org/docs/en/i18n/i18n) ### Plugin A plugin is an independent module that can be added to Day.js to extend functionality or add new features. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand dayjs.extend(advancedFormat) // use plugin dayjs().format('Q Do k kk X x') // more available formats ``` 📚[Plugin List](https://day.js.org/docs/en/plugin/plugin) ## Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor via Github](https://github.com/sponsors/iamkun/)] [[Become a sponsor via OpenCollective](https://opencollective.com/dayjs#sponsor)]                                              Instagram Story Viewer                   BestKru                   Route Optimizer and Route Planner Software                            ## Contributors This project exists thanks to all the people who contribute. Please give us a 💖 star 💖 to support us. Thank you. And thank you to all our backers! 🙏
## License Day.js is licensed under a [MIT License](./LICENSE). ================================================ FILE: babel.config.js ================================================ module.exports = { env: { test: { presets: [ '@babel/preset-env' ] }, build: { presets: [ [ '@babel/preset-env', { modules: false, loose: true } ] ] } } } ================================================ FILE: build/esm.js ================================================ const fs = require('fs') const path = require('path') const util = require('util') const { ncp } = require('ncp') const { promisify } = util const typeFileExt = '.d.ts' const localeDir = path.join(process.env.PWD, 'esm/locale') const pluginDir = path.join(process.env.PWD, 'esm/plugin') const localeTypePath = path.join(process.env.PWD, 'esm/locale', `index${typeFileExt}`); (async () => { try { const readLocaleDir = await promisify(fs.readdir)(localeDir) readLocaleDir.forEach(async (l) => { const filePath = path.join(localeDir, l) const readFile = await promisify(fs.readFile)(filePath, 'utf8') const result = readFile.replace("'dayjs'", "'../index'") await promisify(fs.writeFile)(filePath, result, 'utf8') }) await promisify(ncp)('./types/', './esm') const readLocaleFile = await promisify(fs.readFile)(localeTypePath, 'utf8') const localResult = readLocaleFile.replace("'dayjs", "'dayjs/esm") await promisify(fs.writeFile)(localeTypePath, localResult, 'utf8') const readPluginDir = await promisify(fs.readdir)(pluginDir) readPluginDir.forEach(async (p) => { if (p.includes(typeFileExt)) { const pluginName = p.replace(typeFileExt, '') const filePath = path.join(pluginDir, p) const targetPath = path.join(pluginDir, pluginName, `index${typeFileExt}`) const readFile = await promisify(fs.readFile)(filePath, 'utf8') const result = readFile.replace(/'dayjs'/g, "'dayjs/esm'") await promisify(fs.writeFile)(targetPath, result, 'utf8') await promisify(fs.unlink)(filePath) } }) } catch (e) { console.error(e) // eslint-disable-line no-console } })() ================================================ FILE: build/index.js ================================================ const rollup = require('rollup') const configFactory = require('./rollup.config') const fs = require('fs') const util = require('util') const path = require('path') const { ncp } = require('ncp') const { promisify } = util const promisifyReadDir = promisify(fs.readdir) const promisifyReadFile = promisify(fs.readFile) const promisifyWriteFile = promisify(fs.writeFile) const localeNameRegex = /\/\/ (.*) \[/ const formatName = n => n.replace(/\.js/, '').replace('-', '_') const localePath = path.join(__dirname, '../src/locale') async function build(option) { const bundle = await rollup.rollup(option.input) await bundle.write(option.output) } async function listLocaleJson(localeArr) { const localeListArr = [] await Promise.all(localeArr.map(async (l) => { const localeData = await promisifyReadFile(path.join(localePath, l), 'utf-8') localeListArr.push({ key: l.slice(0, -3), name: localeData.match(localeNameRegex)[1] }) })) promisifyWriteFile(path.join(__dirname, '../locale.json'), JSON.stringify(localeListArr), 'utf8') } (async () => { try { /* eslint-disable no-restricted-syntax, no-await-in-loop */ // We use await-in-loop to make rollup run sequentially to save on RAM const locales = await promisifyReadDir(localePath) for (const l of locales) { // run builds sequentially to limit RAM usage await build(configFactory({ input: `./src/locale/${l}`, fileName: `./locale/${l}`, name: `dayjs_locale_${formatName(l)}` })) } const plugins = await promisifyReadDir(path.join(__dirname, '../src/plugin')) for (const plugin of plugins) { // run builds sequentially to limit RAM usage await build(configFactory({ input: `./src/plugin/${plugin}/index`, fileName: `./plugin/${plugin}.js`, name: `dayjs_plugin_${formatName(plugin)}` })) } build(configFactory({ input: './src/index.js', fileName: './dayjs.min.js' })) await promisify(ncp)('./types/', './') // list locales await listLocaleJson(locales) } catch (e) { console.error(e) // eslint-disable-line no-console } })() ================================================ FILE: build/rollup.config.js ================================================ const babel = require('rollup-plugin-babel') const { terser } = require('rollup-plugin-terser') module.exports = (config) => { const { input, fileName, name } = config return { input: { input, external: [ 'dayjs' ], plugins: [ babel({ exclude: 'node_modules/**' }), terser() ] }, output: { file: fileName, format: 'umd', name: name || 'dayjs', globals: { dayjs: 'dayjs' }, compact: true } } } ================================================ FILE: docs/demo/index.js ================================================ import dayjs from 'dayjs' // basic usage dayjs().format() // parse dayjs('2018-08-08').format() // format dayjs().format('YYYY-MM-DD') // locale dayjs().locale('zh-cn').format() // add dayjs().add(1, 'year').format() // subtract dayjs().subtract(1, 'year').format() // diff dayjs().diff(dayjs().add(1, 'year'), 'year') // isBefore dayjs().isBefore(dayjs().add(1, 'year')) // isAfter dayjs().isAfter(dayjs().subtract(1, 'year')) // isSame dayjs().isSame(dayjs()) // isLeapYear dayjs().isLeapYear() // isBetween dayjs().isBetween(dayjs().subtract(1, 'year'), dayjs().add(1, 'year')) // isSameOrAfter dayjs().isSameOrAfter(dayjs().subtract(1, 'year')) // isSameOrBefore dayjs().isSameOrBefore(dayjs().add(1, 'year')) // startOf dayjs().startOf('year').format() // endOf dayjs().endOf('year').format() // week dayjs().week() // weekday dayjs().weekday() ================================================ FILE: docs/en/API-reference.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/en/I18n.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/en/Installation.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/en/Plugin.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/es-es/API-reference.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/es-es/I18n.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/es-es/Installation.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/es-es/Plugin.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/es-es/README-es-es.md ================================================ Español (España) | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Русский](../ru/README-ru.md) | [עברית](./docs/he/README-he.md)

Day.js

Alternativa rápida y ligera 2kB a Moment.js, con la misma API moderna


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js es una librería minimalista para JavaScript que analiza, valida, manipula y muestra fechas y horas para navegadores modernos, manteniendo una API casi completamente compatible con Moment.js. Si usas o has usado Moment.js, ya sabes usar Day.js ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 API & patrones familiares para usuarios de Moment.js - 💪 Inmutable - 🔥 Encadenable - 🌐 Soporta I18n - 📦 Mini librería de 2kb - 👫 Compatible con todos los navegadores --- # Primeros pasos ### Documentación Puedes encontrar más detalles, la API y otros documentos en [day.js.org](https://day.js.org/) el sitio web. ## Instalación ```console npm install dayjs --save ``` 📚[Guía de instalación](https://day.js.org/docs/en/installation/installation) ## API Es fácil el usar las APIs de Day.js para analizar, validar, manipular y mostrar fechas y horas. ```javascript dayjs('2018-08-08') // analiza dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // da formato dayjs() .set('month', 3) .month() // get & set dayjs().add(1, 'year') // manipula dayjs().isBefore(dayjs()) // consulta ``` 📚[Referencia de la API](https://day.js.org/docs/en/parse/parse) ## I18n Day.js soporta muy bien la internacionalización. Pero no se incluirá en tu compilación final a menos que así lo requieras. ```javascript import 'dayjs/locale/es' // carga bajo demanda dayjs.locale('es') // usar la configuración regional española globalmente dayjs('2018-05-05') .locale('zh-cn') .format() // usar el chino simplificado en una instancia concreta ``` 📚[Internacionalización](https://day.js.org/docs/en/i18n/i18n) ## Complementos Un complemento o _plugin_ es un módulo independiente que puede añadirse a Day.js para extender su funcionalidad o añadir nuevas características. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // carga bajo demanda dayjs.extend(advancedFormat) // uso del complemento dayjs().format('Q Do k kk X x') // ahora tenemos más formatos disponibles ``` 📚[Lista de complementos](https://day.js.org/docs/en/plugin/plugin) ## Patrocinadores Apoya a este proyecto convirtiéndote en un patrocinador. Tu logo aparecerá aquí, enlazado a tu sitio web. [[Conviértete en un patrocinador](https://opencollective.com/dayjs#sponsor)] [![Avatar patrocinador 1](https://opencollective.com/dayjs/sponsor/0/avatar.svg)](https://opencollective.com/dayjs/sponsor/0/website) [![Avatar patrocinador 2](https://opencollective.com/dayjs/sponsor/1/avatar.svg)](https://opencollective.com/dayjs/sponsor/1/website) [![Avatar patrocinador 3](https://opencollective.com/dayjs/sponsor/2/avatar.svg)](https://opencollective.com/dayjs/sponsor/2/website) ## Contribuidores Este proyecto existe gracias a todas las personas que contribuyen en él. Por favor, danos una 💖 estrella 💖 para apoyarnos. Gracias. ¡Y gracias también a todos nuestros micromecenas! 🙏 ## Licencia Day.js está licenciado bajo la [Licencia MIT](./LICENSE). ================================================ FILE: docs/fr/README-fr.md ================================================ Français | [English](../../README.md) | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md) | [සිංහල](./docs/si/README-si.md) | [עברית](./docs/he/README-he.md)

Day.js

Alternative rapide de 2kB à Moment.js avec la même API moderne

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js est une bibliothèque JavaScript minimaliste qui analyse, valide, manipule et affiche les dates et heures pour les navigateurs modernes avec une API largement compatible avec Moment.js. Si vous utilisez Moment.js, vous savez déjà comment utiliser Day.js. ```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` * 🕒 Familiarité avec l'API et les modèles Moment.js * 💪 Immuable * 🔥 Enchaînable * 🌐 Support I18n * 📦 Petite bibliothèque de 2kb * 👫 Tous les navigateurs sont pris en charge --- ## Mise en place ### Documentation Vous trouverez plus de détails sur l'API et les autres documents sur le site [day.js.org](https://day.js.org/). ### Installation ```console npm install dayjs --save ``` 📚[Guide d'installation](https://day.js.org/docs/en/installation/installation) ### API Il est facile d'utiliser les API de Day.js pour analyser, valider, manipuler et afficher des dates et des heures. ```javascript dayjs('2018-08-08') // parse dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display dayjs().set('month', 3).month() // get & set dayjs().add(1, 'year') // manipulate dayjs().isBefore(dayjs()) // query ``` 📚[API Reference](https://day.js.org/docs/en/parse/parse) ### I18n Day.js offre une excellente prise en charge de l'internationalisation. Mais aucun d'entre eu ne sera inclus dans votre construction si vous ne l'utilisez pas. ```javascript import 'dayjs/locale/es' // load on demand dayjs.locale('es') // use Spanish locale globally dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance ``` 📚[Internationalisation](https://day.js.org/docs/en/i18n/i18n) ### Plugin Un plugin est un module indépendant qui peut être ajouté à Day.js pour en étendre les fonctionnalités ou en ajouter de nuovelles. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand dayjs.extend(advancedFormat) // use plugin dayjs().format('Q Do k kk X x') // more available formats ``` 📚[Liste des plugins](https://day.js.org/docs/en/plugin/plugin) ### Tendance d'utilisation ## Sponsors Soutenez ce projet en devenant sponsor. Votre logo apparaîtra ici avec un lien vers votre site web. [[Devenir sponsor via Github](https://github.com/sponsors/iamkun/)] [[Devenir sponsor via OpenCollective](https://opencollective.com/dayjs#sponsor)]                                                                ## Contributeurs Ce projet existe grâce à toutes les personnes qui y contribuent. Donnez-nous une 💖 étoile 💖 pour nous soutenir. Nous vous remercions. Et merci à tous nos donateurs ! 🙏
## Licence Day.js est sous licence [MIT License](./LICENSE). ================================================ FILE: docs/he/README-he.md ================================================
עברית | [English](../../README.md) | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md) | [සිංහල](./docs/si/README-si.md)

Day.js

אלטרנטיבה מהירה ל-Moment.js ששוקלת רק 2kB עם אותן יכולות מודרניות

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js היא ספרייה מינימלסטית לפענוח, אימות, מניפולציה והצגה של תאריכים ושעות לדפדפנים מודרנים עם תאימות גבוהה ל-API של Moment.js. אם השתמשתם ב-Moment.js, אתם כבר יודעים את Day.js
```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ```
* 🕒 תבניות ו-API זהים ל-Moment.js * 💪 אינו ניתן לשינוי * 🔥 ניתן לשרשור * 🌐 תמיכה ב-I18n * 📦 ספרייה קטנטנה 2kb * 👫 נתמכת בכל הדפדפנים --- ## צעדים ראשונים ### דוקומנטצייה באתר [day.js.org](https://day.js.org/) ניתן למצוא פרטים נוספים, API, ותיעודים נוספים. ### התקנה ```console npm install dayjs --save ``` 📚[מדריך התקנה](https://day.js.org/docs/en/installation/installation) ### API מאוד קל להשתמש ב-Day.js לפענוח, אימות, מניפולציה והצגה של תאריכים ושעות.
```javascript dayjs('2018-08-08') // פענוח dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // הצגה dayjs().set('month', 3).month() // קבלה והגדרה dayjs().add(1, 'year') // מניפולציה dayjs().isBefore(dayjs()) // שאילתה ```
📚[תיעודי API](https://day.js.org/docs/en/parse/parse) ### I18n ל-Day.js יש תמיכה מצוינית בבינלאומיות. אבל אף אחד מהם לא יכלל בקובץ הסופי אלא אם כן יתבצע בהם שימוש.
```javascript import 'dayjs/locale/es' // טעינה לפי הצורך dayjs.locale('es') // הגדרה לשימוש בספרדית באופן גלובלאלי dayjs('2018-05-05').locale('zh-cn').format() // הגדרה לשימוש בסינית פשוטה למופע ספיציפי בלבד ```
📚[בינלאומיות](https://day.js.org/docs/en/i18n/i18n) ### תוסף תוסף הוא מודל בלתי-תלוי הניתן להוספה ל-Day.js להרחבה או להוספה של פונקציות.
```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // טעינה לפי הצורך dayjs.extend(advancedFormat) // שימוש בתוסף dayjs().format('Q Do k kk X x') // כעת יותר אפשרויות זמינות ```
📚[רשימת תוספים](https://day.js.org/docs/en/plugin/plugin) ### ספונסרים תמכו בפרויקט זה כדי להיות ספונסר. קבלו לוגו עם קישור לאתר שלכם שיופיע כאן. [[תמיכה דרך Github](https://github.com/sponsors/iamkun/)] [[תמיכה דרך OpenCollective](https://opencollective.com/dayjs#sponsor)]                                                                ## תורמים פרויקט זה קיים הודות לכל האנשים שתמכו בו. תנו לנו 💖 כוכב 💖 כדי לתמוך בנו. תודה רבה. ותודה רבה לכל התומכים שלנו! 🙏
## רישיון Day.js מורשה לשימוש עם [רישיון MIT](./LICENSE).
================================================ FILE: docs/ja/API-reference.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ja/I18n.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ja/Installation.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ja/Plugin.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ja/README-ja.md ================================================ 日本語 | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)| [עברית](../he/README-he.md)

Day.js

Moment.js と同じ API を備えた 2kB の軽量ライブラリ


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js は日付と時刻をパース・検証・操作・表示する最小のモダンブラウザ向け JavaScript ライブラリであり、 Moment.js の API との広い互換性を持ちます。 Moment.js を使ったことがあればすぐにでも Day.js を使い始めることができます。 ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 Moment.js と類似した API と使用法 - 💪 イミュータブル - 🔥 メソッドチェーン - 🌐 国際化サポート (I18n) - 📦 2kb の軽量ライブラリ - 👫 全ブラウザをサポート --- ## はじめに ### ドキュメント 詳細、API、その他のドキュメントについては、[day.js.org](https://day.js.org/) のウェブサイトを参照してください。 ### インストール ```console npm install dayjs --save ``` 📚[インストールガイド](https://day.js.org/docs/en/installation/installation) ### API Day.js API で日付と時刻をパース・検証・操作・表示するのは簡単です。 ```javascript dayjs('2018-08-08') // パース dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // 表示 dayjs() .set('month', 3) .month() // get & set dayjs().add(1, 'year') // 操作 dayjs().isBefore(dayjs()) // クエリ ``` 📚[API リファレンス](https://day.js.org/docs/en/parse/parse) ### 国際化 (I18n) Day.js は国際化を手厚くサポートしています。 また、使用しないロケールをビルドに含みません。 ```javascript import 'dayjs/locale/es' // 必要に応じて読み込み dayjs.locale('es') // スペイン語をグローバルロケールとして適用 dayjs('2018-05-05') .locale('zh-cn') .format() // 簡体字中国語を特定のインスタンスにのみ適用 ``` 📚[国際化](https://day.js.org/docs/en/i18n/i18n) ### プラグイン プラグインとは、 Day.js の機能を拡張したり、新たな機能を追加するための独立したモジュールのことです。 ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // 必要に応じて読み込み dayjs.extend(advancedFormat) // プラグインを使用 dayjs().format('Q Do k kk X x') // 多様なフォーマットが利用可能に ``` 📚[プラグインリスト](https://day.js.org/docs/en/plugin/plugin) ## ライセンス Day.js は [MIT License](../../LICENSE) のもとで利用を許諾します。 ================================================ FILE: docs/ko/API-reference.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ko/I18n.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ko/Installation.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ko/Plugin.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/ko/README-ko.md ================================================ 한국어 | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)| [עברית](./docs/he/README-he.md)

Day.js

Moment.js와 호환되는 API를 가진 경량 라이브러리 (2kB)


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js는 대부분의 API가 Moment.js와 호환되며 최신 브라우저에서 날짜와 시간에 대한 구문 분석, 유효성 검사, 조작, 출력을 간편하게 처리하는 경량 JavaScript 라이브러리 입니다. Moment.js를 사용해본 경험이 있다면, Day.js도 쉽게 사용하실 수 있습니다. ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 친숙한 Moment.js API와 패턴 - 💪 불변 오브젝트(Immutable) - 🔥 메소드 체인(Chainable) - 🌐 I18n 지원 - 📦 2kb 미니 라이브러리 - 👫 모든 브라우저 지원 --- ## 시작해볼까요! ### 문서 더 많은 세부 사항과 API 및 다른 문서는 [day.js.org](https://day.js.org/) 웹사이트에서 확인하실 수 있습니다. ### 설치 ```console npm install dayjs --save ``` 📚[설치 가이드](https://day.js.org/docs/en/installation/installation) ### API Day.js API를 사용하여 날짜와 시간의 구문 분석, 검증, 조작, 출력을 간편하게 처리할 수 있습니다. ```javascript dayjs('2018-08-08') // parse dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display dayjs() .set('month', 3) .month() // get & set dayjs().add(1, 'year') // manipulate dayjs().isBefore(dayjs()) // query ``` 📚[API 참고](https://day.js.org/docs/en/parse/parse) ### I18n Day.js는 국제화에 대한 많은 지원을 제공하고 있습니다. 하지만 이 기능을 사용하지 않는 경우, 빌드에 포함되지 않습니다. ```javascript import 'dayjs/locale/es' // load on demand dayjs.locale('es') // use Spanish locale globally dayjs('2018-05-05') .locale('zh-cn') .format() // use Chinese Simplified locale in a specific instance ``` 📚[I18n](https://day.js.org/docs/en/i18n/i18n) ### Plugin 플러그인은 Day.js의 기능을 확장하거나 새로운 기능을 도입하기 위한 독립적인 모듈입니다. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand dayjs.extend(advancedFormat) // use plugin dayjs().format('Q Do k kk X x') // more available formats ``` 📚[플러그인 목록](https://day.js.org/docs/en/plugin/plugin) ## License Day.js는 [MIT License](./LICENSE)를 사용합니다. ================================================ FILE: docs/pt-br/API-reference.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/pt-br/I18n.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/pt-br/Installation.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/pt-br/Plugin.md ================================================ ### Note The documents are moved to [https://day.js.org](https://day.js.org). ================================================ FILE: docs/pt-br/README-pt-br.md ================================================ Português Brasileiro | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)| [עברית](./docs/he/README-he.md)

Day.js

Alternativa veloz ao Moment.js, com 2kB e a mesma API moderna


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js é uma biblioteca JavaScript minimalista que analisa, valida, manipula e formata datas e horas para navegadores modernos, usando uma API quase completamente compatível com Moment.js. Se você já usou Moment.js, já sabe usar Day.js. ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 API & padrões familiares aos do Moment.js - 💪 Imutável - 🔥 Encadeável - 🌐 Suporta I18n - 📦 Mini biblioteca de 2kb - 👫 Suporta todos os navegadores --- ## Começando ### Documentação Você pode encontrar mais detalhes sobre a API e também a documentação completa em [day.js.org](https://day.js.org/). ### Instalação ```console npm install dayjs --save ``` 📚[Guia de instalação](https://day.js.org/docs/en/installation/installation) ### API É fácil utilizar a API do Day.js para converter, validar, manipular, e exibir datas e horas. ```javascript dayjs('2018-08-08') // converte dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // formata dayjs() .set('month', 3) .month() // get & set dayjs().add(1, 'year') // manipula dayjs().isBefore(dayjs()) // verifica ``` 📚[Referência da API](https://day.js.org/docs/en/parse/parse) ### I18n Day.js tem suporte para internacionalização. Porém nenhuma estará inclusa no seu _build_ a menos que você utilize-a. ```javascript import 'dayjs/locale/es' // carregar sob demanda dayjs.locale('es') // usar locale espanhol globalmente dayjs('2018-05-05') .locale('pt-br') .format() // usar locale em português brasileiro em uma instância específica ``` 📚[Internacionalização](https://day.js.org/docs/en/i18n/i18n) ### Plugin Um plugin é um módulo independente que pode ser adicionado ao Day.js para estender funcionalidades e adicionar novos recursos. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // carregar sob demanda dayjs.extend(advancedFormat) // usar plugin dayjs().format('Q Do k kk X x') // mais formatos disponíveis pelo plugin ``` 📚[Lista de Plugins](https://day.js.org/docs/en/plugin/plugin) ## Patrocinadores Ajude este projeto se tornando um patrocinador. O seu logo será exibido aqui, com um link para o seu site. [[Tornar-se um Patrocinador](https://opencollective.com/dayjs#sponsor)]. ## Contribuidores Este projeto existe graças a todas as pessoas que contribuem. Por favor, nos dê uma 💖 estrela 💖 para suportar-nos. Obrigado. E obrigado a todos os nossos apoiadores! 🙏 ## Licença Day.js é licenciado sob a [MIT License](../../LICENSE). ================================================ FILE: docs/ru/LICENSE-ru ================================================ Лицензия MIT Авторское право (c) с 2018 года по настоящее время, iamkun Данная лицензия разрешает лицам, получившим копию данного программного обеспечения и сопутствующей документации (в дальнейшем именуемыми «Программное обеспечение»), безвозмездно использовать Программное обеспечение без ограничений, включая неограниченное право на использование, копирование, изменение, слияние, публикацию, распространение, сублицензирование и/или продажу копий Программного обеспечения, а также лицам, которым предоставляется данное Программное обеспечение, при соблюдении следующих условий: Указанное выше уведомление об авторском праве и данные условия должны быть включены во все копии или значимые части данного Программного обеспечения. ДАННОЕ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ «КАК ЕСТЬ», БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, ЯВНО ВЫРАЖЕННЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ ГАРАНТИИ ТОВАРНОЙ ПРИГОДНОСТИ, СООТВЕТСТВИЯ ПО ЕГО КОНКРЕТНОМУ НАЗНАЧЕНИЮ И ОТСУТСТВИЯ НАРУШЕНИЙ, НО НЕ ОГРАНИЧИВАЯСЬ ИМИ. НИ В КАКОМ СЛУЧАЕ АВТОРЫ ИЛИ ПРАВООБЛАДАТЕЛИ НЕ НЕСУТ ОТВЕТСТВЕННОСТИ ПО КАКИМ-ЛИБО ИСКАМ, ЗА УЩЕРБ ИЛИ ПО ИНЫМ ТРЕБОВАНИЯМ, В ТОМ ЧИСЛЕ, ПРИ ДЕЙСТВИИ КОНТРАКТА, ДЕЛИКТЕ ИЛИ ИНОЙ СИТУАЦИИ, ВОЗНИКШИМ ИЗ-ЗА ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ИЛИ ИНЫХ ДЕЙСТВИЙ С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ. ================================================ FILE: docs/ru/README-ru.md ================================================ Русский | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md)| [עברית](./docs/he/README-he.md)

Day.js

Быстрая 2kB альтернатива Moment.js с тем же современным API


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js - это миниатюрная JavaScript библиотека, которая парсит, валидирует, управляет, и отображает даты и время для современных браузеров, обладающая большой совместимостью с Moment.js API. Если вы используете Moment.js, вы уже знаете как пользоваться Day.js. ```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` * 🕒 Хорошо знакомые API и паттерны Moment.js * 💪 Неизменная * 🔥 Цепная * 🌐 Поддержка интернационализации (I18n) * 📦 2kb мини-библиотека * 👫 Поддерживающаяся всеми браузерами --- ## Начало работы ### Документация Вы можете найти больше детальной информации, API, и других документов на веб-сайте [day.js.org](https://day.js.org/). ### Установка ```console npm install dayjs --save ``` 📚[Инструкция по установке](https://day.js.org/docs/en/installation/installation) ### API API Day.js легко использовать для парсинга, валидации, управления, и отображения дат и времени. ```javascript dayjs('2018-08-08') // парсинг dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // отображение dayjs().set('month', 3).month() // получение и установка dayjs().add(1, 'year') // управление dayjs().isBefore(dayjs()) // осведомление ``` 📚[Ссылка на API](https://day.js.org/docs/en/parse/parse) ### I18n Day.js обладает великолепной поддержкой интернационализации. Но ни одна из локализаций не будет включена в вашу сборку до тех пор, пока вы не начнёте её использовать. ```javascript import 'dayjs/locale/es' // загрузка по требованию dayjs.locale('es') // глобальное использование Испанской локали dayjs('2018-05-05').locale('zh-cn').format() // использование упрощённой Китайской локали в конкретном случае ``` 📚[Интернационализация](https://day.js.org/docs/en/i18n/i18n) ### Плагин Плагин - это независимый модуль, который может быть добавлен в Day.js с целью расширения функциональных возможностей или добавления новых особенностей. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // загрузка по требованию dayjs.extend(advancedFormat) // использование плагина dayjs().format('Q Do k kk X x') // больше доступных форматов ``` 📚[Список плагинов](https://day.js.org/docs/en/plugin/plugin) ## Спонсоры Поддержите этот проект, став спонсором. Ваш логотип будет показан здесь с ссылкой на ваш веб-сайт. [[Стать спонсором](https://opencollective.com/dayjs#sponsor)] ## Контрибьюторы Этот проект существует благодаря всем людям, кто вносит свой вклад в его развитие. Пожалуйста поставьте 💖 звездочку 💖, чтобы поддержать нас. Спасибо. Также выражаю благодарность всем нашим спонсорам! 🙏 ## Лицензия Day.js распространяется под [лицензией MIT](./LICENSE-ru). ================================================ FILE: docs/si/README-si.md ================================================ සිංහල | [English](../../README.md) | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md)| [עברית](./docs/he/README-he.md)

Day.js

නවීන යෙ.ක්‍ර.මු. සමඟින් Moment.js සඳහා කි.බ. 2 ක වේගවත් විකල්පයකි

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js යනු බොහෝ සෙයින් Moment.js-ගැළපෙන යෙ.ක්‍ර.මු. සහිත නවීන අතිරික්සු සඳහා දින සහ වේලාවන් ප්‍රදර්ශනයට, හැසිරවීමට, වලංගු කිරීමට සහ විග්‍රහ කිරීමට ඉතා කුඩා ජාවාස්ක්‍රිප්ට් එකතුවකි. Moment.js භාවිතා කරන්නේ නම්, Day.js භාවිතා කරන අයුරු ඔබ දැනටමත් දන්නවා. ```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` * 🕒 හුරුපුරුදු Moment.js යෙ.ක්‍ර.මු. හා රටා * 💪 නිත්‍යයි * 🔥 ඈඳීමට හැකිය * 🌐 I18n සහාය * 📦 කි.බ. 2 ක කුඩා එකතුව * 👫 සියළු අතිරික්සු සඳහා සහාය --- ## පටන් ගැනීම ### ප්‍රලේඛනය [day.js.org](https://day.js.org/) වියමන අඩවියෙහි යෙ.ක්‍ර.මු. සහ වෙනත් ප්‍රලේඛනවල වැඩි විස්තර සොයා ගැනීමට හැකිය. ### ස්ථාපනය ```console npm install dayjs --save ``` 📚[ ස්ථාපන මාර්ගෝපදේශය](https://day.js.org/docs/en/installation/installation) ### යෙ.ක්‍ර.මු. දින සහ වේලාවන් ප්‍රදර්ශනයට, හැසිරවීමට, වලංගු කිරීමට සහ විග්‍රහ කිරීමට Day.js යෙ.ක්‍ර.මු. භාවිතා කිරීම පහසුය. ```javascript dayjs('2018-08-08') // parse dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display dayjs().set('month', 3).month() // get & set dayjs().add(1, 'year') // manipulate dayjs().isBefore(dayjs()) // query ``` 📚[ යෙ.ක්‍ර.මු. යොමුව](https://day.js.org/docs/en/parse/parse) ### I18n දේශීයකරණය සඳහා Day.js සුවිශේෂී ලෙස සහය දක්වයි. නමුත් භාවිතා කරන්නේ නම් මිස ඒවා කිසිවක් ඔබගේ තැනීමට ඇතුළත් නොවේ. ```javascript import 'dayjs/locale/es' // load on demand dayjs.locale('es') // use Spanish locale globally dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance ``` 📚[ දේශීයකරණය](https://day.js.org/docs/en/i18n/i18n) ### දිගුව දිගුවක් යනු ක්‍රියාකාරිත්වය විස්තීරණයට හෝ නව විශේෂාංග අඩංගු කිරීමට Day.js වෙත එකතු කළ හැකි ස්වාධීන ඒකකයකි. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand dayjs.extend(advancedFormat) // use plugin dayjs().format('Q Do k kk X x') // more available formats ``` 📚[ දිගු ලේඛනය](https://day.js.org/docs/en/plugin/plugin) ## අනුග්‍රාහකයින් අනුග්‍රහය දැක්වීමෙන් මෙම ව්‍යාපෘතියට සහාය වන්න. ඔබගේ අඩවියේ සබැඳියක් සමඟ ඔබගේ ලාංඡනය මෙහි පෙන්වනු ඇත. [[ගිට්හබ් හරහා අනුග්‍රාහකයෙකු වන්න](https://github.com/sponsors/iamkun/)] [[ඕපන්කලෙක්ටිව් හරහා අනුග්‍රාහකයෙකු වන්න](https://opencollective.com/dayjs#sponsor)]                                     ## දායකයින් මෙම ව්‍යාපෘතිය පවතිනුයේ දායක වූ සියළුම දෙනාට ස්තූති වන්නටය. අපට සහාය වීමට 💖 තරුවක් 💖 ලබා දෙන්න. ඔබට තුති. ඒ වගේම අපගේ මූල්‍යදායකයින් සැමට ස්තුතියි! 🙏 ## බලපත්‍රය [MIT බලපත්‍රයක්](./LICENSE) යටතේ Day.js නිකුත් කර ඇත. ================================================ FILE: docs/sw/README-sw.md ================================================ Swahili | [English](../../README.md) | [Kireno](../pt-br/README-pt-br.md) | [Kichina](../zh-cn/README.zh-CN.md) | [Kijapani](../ja/README-ja.md) | [Kikorea](../ko/README-ko.md) | [Kihispania](../es-es/README-es-es.md) | [Kirusi](../ru/README-ru.md) | [Kituruki](../tr/README-tr.md) | [Sinhala](../si/README-si.md) | [Kiebrania](../he/README-he.md)

Day.js

Fast 2kB mbadala wa Moment.js ukiwa na API zinazofanana na za kisasa

Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js ni Maktaba ya JavaScript ya minimalist ambayo inachanganua, kuthibitisha, kudhibiti, na kuonyesha tarehe na nyakati kwa vivinjari vya kisasa na API inayofanana sana na Moment.js. Ikiwa unatumia Moment.js, tayari unajua jinsi ya kutumia Day.js. ```js dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` * 🕒 Michoro na API maarufu za Moment.js * 💪 Hazibadiliki * 🔥 Zinaunganishwa * 🌐 Zinaruhusu I18n * 📦 Maktaba ndogo ya 2kb * 👫 Browser zote zinaruhusu --- ## Kuanza ### Nyaraka Unaweza kutafuta maelekezo zaidi ya API na nyaraka zingine kupitia tovuti ya [day.js.org](https://day.js.org/). ### Kusakinisha ```console npm install dayjs --save ``` 📚[Maelekezo ya Kusakinisha](https://day.js.org/docs/en/installation/installation) ### API Ni rahisi kutumia Day.js kupitisha, kuhakiki, kubadili na kuonesha tarehe na mda. ```javascript dayjs('2018-08-08') // changanua dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display dayjs().set('month', 3).month() // chukua na weka dayjs().add(1, 'year') // manipulate dayjs().isBefore(dayjs()) // query ``` 📚[Maelekezo Ya API](https://day.js.org/docs/en/parse/parse) ### I18n Day.js ina ruhusu kwa internalization. Lakini hakuna hata moja ambayo itawekwa katika utengezaji endapo utatumia. ```javascript import 'dayjs/locale/es' // load on demand dayjs.locale('es') // use Spanish locale globally dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance ``` 📚[Internationalization](https://day.js.org/docs/en/i18n/i18n) ### Zana Zana ya Kujumuisha ni moduli inayojitegemea ambayo inaweza ikaweka katika Day.js ili kuweza kuongeza uwezo au kuongeza sifa. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // Upakiaji kwa Mahitaji dayjs.extend(advancedFormat) // tumia plugin dayjs().format('Q Do k kk X x') // njia zaidi zilizopo ``` 📚[Idadi Ya Plugin](https://day.js.org/docs/en/plugin/plugin) ### Trend Zinazoweza Tumika ## Wafadhili Toa mchango wako kwa huu mradi kwa kuwa mfadhili. Nembo yako itaonekana hapa pamoja na link ya kwenda kwenye tovuti yako. [[Kuwa mfadhili kupitia GitHub](https://github.com/sponsors/iamkun/)] [[Kuwa mfadhili kupitia OpenCollective](https://opencollective.com/dayjs#sponsor)]                                                       BestKru ## Wachangiaji Huu mradi umefika hapa ulipo hapa shukrani ziende kwa watu wote wanao changia. Tafadhali tupe 💖 nyota/maua 💖 kutuunga mkono sisi.Ahsante. Na ahsante kwa wafadhili wote! 🙏
## Leseni Day.js ipo chini ya kibali cha [leseni ya MTI](./LICENSE). ================================================ FILE: docs/tr/README-tr.md ================================================ Türkçe | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)| [עברית](./docs/he/README-he.md)

Day.js

Aynı modern API ile 2kB hızlı bir Moment.js alternatifi


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js, büyük ölçüde Moment.js uyumlu bir API ile modern tarayıcılar için tarih ve saatleri dönüştüren, doğrulayan, işleyen ve görüntüleyen minimalist bir JavaScript kütüphanesidir. Moment.js kullanıyorsanız, Day.js'i nasıl kullanacağınızı zaten biliyorsunuzdur. ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 Benzer Moment.js API & Kalıpları - 💪 Değişmez - 🔥 Zincirlenebilir - 🌐 I18n destekler - 📦 2kB boyutunda küçük bir kütaphane - 👫 Bütün tarayıcılarda desteklenir --- # Başlarken ### Dökümantasyon Daha fazla bilgiye, API ve diğer dökümanlara [day.js.org](https://day.js.org/) websitesinden ulaşabilirsiniz. ## Kurulum ```console npm install dayjs --save ``` 📚[Kurulum Rehberi](https://day.js.org/docs/en/installation/installation) ## API Tarihleri ve saatleri dönüştürmek, doğrulamak, işlemek ve görüntülemek için Day.js API'larını kullanmak kolaydır. ```javascript dayjs('2018-08-08') // dönüştürme dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // belirli bir formatta görüntüleme dayjs() .set('month', 3) .month() // görüntüleme & değer atama dayjs().add(1, 'year') // değiştirme dayjs().isBefore(dayjs()) // sorgulama ``` 📚[API Referansı](https://day.js.org/docs/en/parse/parse) ## I18n Day.js, uluslararasılaştırma için büyük desteğe sahiptir. Ancak siz kullanmadığınız sürece bunların hiçbiri yapınıza dahil edilmeyecektir. ```javascript import 'dayjs/locale/es' // isteğe göre yükle dayjs.locale('tr') // yerel ayarı Türkçe olarak kullan dayjs('2018-05-05') .locale('zh-cn') .format() //belirli bir durum için Basitleştirilmiş Çince formatında görüntüleme ``` 📚[Uluslararasılaştırma](https://day.js.org/docs/en/i18n/i18n) ## Eklenti Eklenti, işlevselliği genişletmek veya yeni özellikler eklemek için Day.js'e eklenebilen bağımsız bir modüldür. ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // isteğe göre yükle dayjs.extend(advancedFormat) // eklentiyi kullan dayjs().format('Q Do k kk X x') // diğer mevcut formatlar ``` 📚[Eklenti Listesi](https://day.js.org/docs/en/plugin/plugin) ## Sponsorlar Sponsor olarak bu projeye destek olun. Logonuz, web sayfanızın linki ile birlikte burada görünür. [[Sponsor Ol](https://opencollective.com/dayjs#sponsor)] ## Katkıda Bulunanlar Bu proje, katkıda bulunan tüm insanlar sayesinde mevcut. Lütfen bize destek olmak için projeye 💖 yıldız 💖 verin. Teşekkürler. Ve tüm destekçilerimize teşekkür ederiz! 🙏 ## Lisans Day.js, bir [MIT Lisansı](../../LICENSE) altında lisanslanmıştır. ================================================ FILE: docs/zh-cn/API-reference.md ================================================ ### 提醒 文档已迁移至 [https://day.js.org](https://day.js.org)。 ================================================ FILE: docs/zh-cn/I18n.md ================================================ ### 提醒 文档已迁移至 [https://day.js.org](https://day.js.org)。 ================================================ FILE: docs/zh-cn/Installation.md ================================================ ### 提醒 文档已迁移至 [https://day.js.org](https://day.js.org)。 ================================================ FILE: docs/zh-cn/Plugin.md ================================================ ### 提醒 文档已迁移至 [https://day.js.org](https://day.js.org)。 ================================================ FILE: docs/zh-cn/README.zh-CN.md ================================================ 简体中文 | [English](../../README.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)

Day.js

Moment.js 的 2kB 轻量化方案,拥有同样强大的 API


Gzip Size NPM Version Build Status Codecov License
Sauce Test Status

> Day.js 是一个轻量的处理时间和日期的 JavaScript 库,和 Moment.js 的 API 设计保持完全一样. 如果您曾经用过 Moment.js, 那么您已经知道如何使用 Day.js ```js dayjs() .startOf('month') .add(1, 'day') .set('year', 2018) .format('YYYY-MM-DD HH:mm:ss') ``` - 🕒 和 Moment.js 相同的 API 和用法 - 💪 不可变数据 (Immutable) - 🔥 支持链式操作 (Chainable) - 🌐 国际化 I18n - 📦 仅 2kb 大小的微型库 - 👫 全浏览器兼容 --- ## 快速开始 ### 文档 访问 [day.js.org](https://day.js.org/) 网站查看更详细的文档 ### 安装 ```console npm install dayjs --save ``` 📚[安装指南](https://day.js.org/docs/zh-CN/installation/installation) ### API Day.js 有很多 API 来解析、处理、校验、增减、展示时间和日期 ```javascript dayjs('2018-08-08') // 解析 dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // 展示 dayjs() .set('month', 3) .month() // 获取 dayjs().add(1, 'year') // 处理 dayjs().isBefore(dayjs()) // 查询 ``` 📚[API 参考](https://day.js.org/docs/zh-CN/parse/parse) ### 国际化 I18n Day.js 支持国际化 但除非手动加载,多国语言默认是不会被打包到工程里的 ```javascript import 'dayjs/locale/es' // 按需加载 dayjs.locale('es') // 全局使用西班牙语 dayjs('2018-05-05') .locale('zh-cn') .format() // 在这个实例上使用简体中文 ``` 📚[国际化 I18n](https://day.js.org/docs/zh-CN/i18n/i18n) ### 插件 插件是一些独立的程序,可以给 Day.js 增加新功能和扩展已有功能 ```javascript import advancedFormat from 'dayjs/plugin/advancedFormat' // 按需加载插件 dayjs.extend(advancedFormat) // 使用插件 dayjs().format('Q Do k kk X x') // 使用扩展后的API ``` 📚[插件列表](https://day.js.org/docs/zh-CN/plugin/plugin) ## 开源协议 Day.js 遵循 [MIT 开源协议](../../LICENSE). ================================================ FILE: karma.sauce.conf.js ================================================ module.exports = function (config) { const batches = [ { sl_chrome_26: { base: 'SauceLabs', browserName: 'chrome', version: '26' }, sl_chrome: { base: 'SauceLabs', browserName: 'chrome' }, sl_firefox_4: { base: 'SauceLabs', browserName: 'firefox', version: '4' }, sl_firefox: { base: 'SauceLabs', browserName: 'firefox' }, sl_mac_safari_8: { base: 'SauceLabs', browserName: 'safari', version: '8', platform: 'OS X 10.10' }, sl_mac_safari: { base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13' } }, { sl_ie_9: { base: 'SauceLabs', browserName: 'internet explorer', version: '9' }, sl_ie: { base: 'SauceLabs', browserName: 'internet explorer' }, sl_edge_13: { base: 'SauceLabs', browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '13' }, sl_edge: { base: 'SauceLabs', browserName: 'MicrosoftEdge' } }, { sl_ios_safari_9: { base: 'SauceLabs', browserName: 'iphone', version: '9.3' }, sl_android_4_4: { base: 'SauceLabs', browserName: 'android', version: '4.4' } }, { sl_ios_safari: { base: 'SauceLabs', browserName: 'iphone' }, sl_android: { base: 'SauceLabs', browserName: 'android' } } ] const batch = batches[process.argv[4] || 0] config.set({ basePath: '', frameworks: ['jasmine'], files: [ 'dayjs.min.js', 'test/*spec.js' ], reporters: ['dots', 'saucelabs'], port: 9876, colors: true, logLevel: config.LOG_DEBUG, sauceLabs: { // build: 'Manual', testName: 'Day.js' }, captureTimeout: 200000, // try fix ios timeout customLaunchers: batch, browsers: Object.keys(batch), singleRun: true }) } ================================================ FILE: package.json ================================================ { "name": "dayjs", "version": "0.0.0-development", "description": "2KB immutable date time library alternative to Moment.js with the same modern API ", "main": "dayjs.min.js", "types": "index.d.ts", "scripts": { "test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && TZ=America/Whitehorse npm run test-tz && npm run test-tz && jest --coverage --coverageThreshold='{ \"global\": { \"lines\": 100} }'", "test-tz": "date && jest test/timezone.test --coverage=false", "lint": "./node_modules/.bin/eslint src/* test/* build/*", "prettier": "prettier --write \"docs/**/*.md\"", "babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files && node build/esm", "build": "cross-env BABEL_ENV=build node build && npm run size", "sauce": "npx karma start karma.sauce.conf.js", "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2 && npm run sauce -- 3", "size": "size-limit && gzip-size dayjs.min.js" }, "pre-commit": [ "lint" ], "size-limit": [ { "limit": "2.99 KB", "path": "dayjs.min.js" } ], "jest": { "roots": [ "test" ], "testRegex": "test/(.*?/)?.*test.js$", "testURL": "http://localhost", "coverageDirectory": "./coverage/", "collectCoverage": true, "collectCoverageFrom": [ "src/**/*" ] }, "keywords": [ "dayjs", "date", "time", "immutable", "moment" ], "author": "iamkun", "license": "MIT", "homepage": "https://day.js.org", "repository": { "type": "git", "url": "https://github.com/iamkun/dayjs.git" }, "devDependencies": { "@babel/cli": "^7.0.0-beta.44", "@babel/core": "^7.0.0-beta.44", "@babel/node": "^7.0.0-beta.44", "@babel/preset-env": "^7.0.0-beta.44", "@semantic-release/github": "^11.0.4", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^22.4.3", "babel-plugin-external-helpers": "^6.22.0", "cross-env": "^5.1.6", "eslint": "^4.19.1", "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.10.0", "eslint-plugin-jest": "^21.15.0", "gzip-size-cli": "^2.1.0", "jasmine-core": "^2.99.1", "jest": "^22.4.3", "karma": "^2.0.2", "karma-jasmine": "^1.1.2", "karma-sauce-launcher": "^1.1.0", "mockdate": "^2.0.2", "moment": "2.29.2", "moment-timezone": "0.5.31", "ncp": "^2.0.0", "pre-commit": "^1.2.2", "prettier": "^1.16.1", "rollup": "^2.45.1", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^7.0.2", "size-limit": "^0.18.0", "typescript": "^2.8.3" } } ================================================ FILE: patches/@semantic-release+github+11.0.4.patch ================================================ diff --git a/node_modules/@semantic-release/github/lib/success.js b/node_modules/@semantic-release/github/lib/success.js index 29c8def..7e57161 100644 --- a/node_modules/@semantic-release/github/lib/success.js +++ b/node_modules/@semantic-release/github/lib/success.js @@ -118,6 +118,8 @@ export default async function success(pluginConfig, context, { Octokit }) { const uniqueAssociatedPRs = uniqBy(flatten(associatedPRs), "number"); const prs = await pFilter(uniqueAssociatedPRs, async ({ number }) => { + console.log('number: ', number); + if (number < 2000) return false; const commits = await octokit.paginate( "GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { ================================================ FILE: prettier.config.js ================================================ module.exports = { useTabs: false, printWidth: 80, singleQuote: true, trailingComma: 'none', semi: false } ================================================ FILE: src/constant.js ================================================ export const SECONDS_A_MINUTE = 60 export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60 export const SECONDS_A_DAY = SECONDS_A_HOUR * 24 export const SECONDS_A_WEEK = SECONDS_A_DAY * 7 export const MILLISECONDS_A_SECOND = 1e3 export const MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND export const MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND export const MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND export const MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND // English locales export const MS = 'millisecond' export const S = 'second' export const MIN = 'minute' export const H = 'hour' export const D = 'day' export const W = 'week' export const M = 'month' export const Q = 'quarter' export const Y = 'year' export const DATE = 'date' export const FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ' export const INVALID_DATE_STRING = 'Invalid Date' // regex export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/ export const REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g ================================================ FILE: src/index.js ================================================ import * as C from './constant' import en from './locale/en' import U from './utils' let L = 'en' // global locale const Ls = {} // global loaded locale Ls[L] = en const IS_DAYJS = '$isDayjsObject' // eslint-disable-next-line no-use-before-define const isDayjs = d => d instanceof Dayjs || !!(d && d[IS_DAYJS]) const parseLocale = (preset, object, isLocal) => { let l if (!preset) return L if (typeof preset === 'string') { const presetLower = preset.toLowerCase() if (Ls[presetLower]) { l = presetLower } if (object) { Ls[presetLower] = object l = presetLower } const presetSplit = preset.split('-') if (!l && presetSplit.length > 1) { return parseLocale(presetSplit[0]) } } else { const { name } = preset Ls[name] = preset l = name } if (!isLocal && l) L = l return l || (!isLocal && L) } const dayjs = function (date, c) { if (isDayjs(date)) { return date.clone() } // eslint-disable-next-line no-nested-ternary const cfg = typeof c === 'object' ? c : {} cfg.date = date cfg.args = arguments// eslint-disable-line prefer-rest-params return new Dayjs(cfg) // eslint-disable-line no-use-before-define } const wrapper = (date, instance) => dayjs(date, { locale: instance.$L, utc: instance.$u, x: instance.$x, $offset: instance.$offset // todo: refactor; do not use this.$offset in you code }) const Utils = U // for plugin use Utils.l = parseLocale Utils.i = isDayjs Utils.w = wrapper const parseDate = (cfg) => { const { date, utc } = cfg if (date === null) return new Date(NaN) // null is invalid if (Utils.u(date)) return new Date() // today if (date instanceof Date) return new Date(date) if (typeof date === 'string' && !/Z$/i.test(date)) { const d = date.match(C.REGEX_PARSE) if (d) { const m = d[2] - 1 || 0 const ms = (d[7] || '0').substring(0, 3) if (utc) { return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms)) } return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms) } } return new Date(date) // everything else } class Dayjs { constructor(cfg) { this.$L = parseLocale(cfg.locale, null, true) this.parse(cfg) // for plugin this.$x = this.$x || cfg.x || {} this[IS_DAYJS] = true } parse(cfg) { this.$d = parseDate(cfg) this.init() } init() { const { $d } = this this.$y = $d.getFullYear() this.$M = $d.getMonth() this.$D = $d.getDate() this.$W = $d.getDay() this.$H = $d.getHours() this.$m = $d.getMinutes() this.$s = $d.getSeconds() this.$ms = $d.getMilliseconds() } // eslint-disable-next-line class-methods-use-this $utils() { return Utils } isValid() { return !(this.$d.toString() === C.INVALID_DATE_STRING) } isSame(that, units) { const other = dayjs(that) return this.startOf(units) <= other && other <= this.endOf(units) } isAfter(that, units) { return dayjs(that) < this.startOf(units) } isBefore(that, units) { return this.endOf(units) < dayjs(that) } $g(input, get, set) { if (Utils.u(input)) return this[get] return this.set(set, input) } unix() { return Math.floor(this.valueOf() / 1000) } valueOf() { // timezone(hour) * 60 * 60 * 1000 => ms return this.$d.getTime() } startOf(units, startOf) { // startOf -> endOf const isStartOf = !Utils.u(startOf) ? startOf : true const unit = Utils.p(units) const instanceFactory = (d, m) => { const ins = Utils.w(this.$u ? Date.UTC(this.$y, m, d) : new Date(this.$y, m, d), this) return isStartOf ? ins : ins.endOf(C.D) } const instanceFactorySet = (method, slice) => { const argumentStart = [0, 0, 0, 0] const argumentEnd = [23, 59, 59, 999] return Utils.w(this.toDate()[method].apply( // eslint-disable-line prefer-spread this.toDate('s'), (isStartOf ? argumentStart : argumentEnd).slice(slice) ), this) } const { $W, $M, $D } = this const utcPad = `set${this.$u ? 'UTC' : ''}` switch (unit) { case C.Y: return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11) case C.M: return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1) case C.W: { const weekStart = this.$locale().weekStart || 0 const gap = ($W < weekStart ? $W + 7 : $W) - weekStart return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M) } case C.D: case C.DATE: return instanceFactorySet(`${utcPad}Hours`, 0) case C.H: return instanceFactorySet(`${utcPad}Minutes`, 1) case C.MIN: return instanceFactorySet(`${utcPad}Seconds`, 2) case C.S: return instanceFactorySet(`${utcPad}Milliseconds`, 3) default: return this.clone() } } endOf(arg) { return this.startOf(arg, false) } $set(units, int) { // private set const unit = Utils.p(units) const utcPad = `set${this.$u ? 'UTC' : ''}` const name = { [C.D]: `${utcPad}Date`, [C.DATE]: `${utcPad}Date`, [C.M]: `${utcPad}Month`, [C.Y]: `${utcPad}FullYear`, [C.H]: `${utcPad}Hours`, [C.MIN]: `${utcPad}Minutes`, [C.S]: `${utcPad}Seconds`, [C.MS]: `${utcPad}Milliseconds` }[unit] const arg = unit === C.D ? this.$D + (int - this.$W) : int if (unit === C.M || unit === C.Y) { // clone is for badMutable plugin const date = this.clone().set(C.DATE, 1) date.$d[name](arg) date.init() this.$d = date.set(C.DATE, Math.min(this.$D, date.daysInMonth())).$d } else if (name) this.$d[name](arg) this.init() return this } set(string, int) { return this.clone().$set(string, int) } get(unit) { return this[Utils.p(unit)]() } add(number, units) { number = Number(number) // eslint-disable-line no-param-reassign const unit = Utils.p(units) const instanceFactorySet = (n) => { const d = dayjs(this) return Utils.w(d.date(d.date() + Math.round(n * number)), this) } if (unit === C.M) { return this.set(C.M, this.$M + number) } if (unit === C.Y) { return this.set(C.Y, this.$y + number) } if (unit === C.D) { return instanceFactorySet(1) } if (unit === C.W) { return instanceFactorySet(7) } const step = { [C.MIN]: C.MILLISECONDS_A_MINUTE, [C.H]: C.MILLISECONDS_A_HOUR, [C.S]: C.MILLISECONDS_A_SECOND }[unit] || 1 // ms const nextTimeStamp = this.$d.getTime() + (number * step) return Utils.w(nextTimeStamp, this) } subtract(number, string) { return this.add(number * -1, string) } format(formatStr) { const locale = this.$locale() if (!this.isValid()) return locale.invalidDate || C.INVALID_DATE_STRING const str = formatStr || C.FORMAT_DEFAULT const zoneStr = Utils.z(this) const { $H, $m, $M } = this const { weekdays, months, meridiem } = locale const getShort = (arr, index, full, length) => ( (arr && (arr[index] || arr(this, str))) || full[index].slice(0, length) ) const get$H = num => ( Utils.s($H % 12 || 12, num, '0') ) const meridiemFunc = meridiem || ((hour, minute, isLowercase) => { const m = (hour < 12 ? 'AM' : 'PM') return isLowercase ? m.toLowerCase() : m }) const matches = (match) => { switch (match) { case 'YY': return String(this.$y).slice(-2) case 'YYYY': return Utils.s(this.$y, 4, '0') case 'M': return $M + 1 case 'MM': return Utils.s($M + 1, 2, '0') case 'MMM': return getShort(locale.monthsShort, $M, months, 3) case 'MMMM': return getShort(months, $M) case 'D': return this.$D case 'DD': return Utils.s(this.$D, 2, '0') case 'd': return String(this.$W) case 'dd': return getShort(locale.weekdaysMin, this.$W, weekdays, 2) case 'ddd': return getShort(locale.weekdaysShort, this.$W, weekdays, 3) case 'dddd': return weekdays[this.$W] case 'H': return String($H) case 'HH': return Utils.s($H, 2, '0') case 'h': return get$H(1) case 'hh': return get$H(2) case 'a': return meridiemFunc($H, $m, true) case 'A': return meridiemFunc($H, $m, false) case 'm': return String($m) case 'mm': return Utils.s($m, 2, '0') case 's': return String(this.$s) case 'ss': return Utils.s(this.$s, 2, '0') case 'SSS': return Utils.s(this.$ms, 3, '0') case 'Z': return zoneStr // 'ZZ' logic below default: break } return null } return str.replace(C.REGEX_FORMAT, (match, $1) => $1 || matches(match) || zoneStr.replace(':', '')) // 'ZZ' } utcOffset() { // Because a bug at FF24, we're rounding the timezone offset around 15 minutes // https://github.com/moment/moment/pull/1871 return -Math.round(this.$d.getTimezoneOffset() / 15) * 15 } diff(input, units, float) { const unit = Utils.p(units) const that = dayjs(input) const zoneDelta = (that.utcOffset() - this.utcOffset()) * C.MILLISECONDS_A_MINUTE const diff = this - that const getMonth = () => Utils.m(this, that) let result switch (unit) { case C.Y: result = getMonth() / 12 break case C.M: result = getMonth() break case C.Q: result = getMonth() / 3 break case C.W: result = (diff - zoneDelta) / C.MILLISECONDS_A_WEEK break case C.D: result = (diff - zoneDelta) / C.MILLISECONDS_A_DAY break case C.H: result = diff / C.MILLISECONDS_A_HOUR break case C.MIN: result = diff / C.MILLISECONDS_A_MINUTE break case C.S: result = diff / C.MILLISECONDS_A_SECOND break default: result = diff // milliseconds break } return float ? result : Utils.a(result) } daysInMonth() { return this.endOf(C.M).$D } $locale() { // get locale object return Ls[this.$L] } locale(preset, object) { if (!preset) return this.$L const that = this.clone() const nextLocaleName = parseLocale(preset, object, true) if (nextLocaleName) that.$L = nextLocaleName return that } clone() { return Utils.w(this.$d, this) } toDate() { return new Date(this.valueOf()) } toJSON() { return this.isValid() ? this.toISOString() : null } toISOString() { // ie 8 return // new Dayjs(this.valueOf() + this.$d.getTimezoneOffset() * 60000) // .format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') return this.$d.toISOString() } toString() { return this.$d.toUTCString() } } const proto = Dayjs.prototype dayjs.prototype = proto; [ ['$ms', C.MS], ['$s', C.S], ['$m', C.MIN], ['$H', C.H], ['$W', C.D], ['$M', C.M], ['$y', C.Y], ['$D', C.DATE] ].forEach((g) => { proto[g[1]] = function (input) { return this.$g(input, g[0], g[1]) } }) dayjs.extend = (plugin, option) => { if (!plugin.$i) { // install plugin only once plugin(option, Dayjs, dayjs) plugin.$i = true } return dayjs } dayjs.locale = parseLocale dayjs.isDayjs = isDayjs dayjs.unix = timestamp => ( dayjs(timestamp * 1e3) ) dayjs.en = Ls[L] dayjs.Ls = Ls dayjs.p = {} export default dayjs ================================================ FILE: src/locale/af.js ================================================ // Afrikaans [af] import dayjs from 'dayjs' const locale = { name: 'af', weekdays: 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'), months: 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'), weekStart: 1, weekdaysShort: 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'), monthsShort: 'Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'), weekdaysMin: 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'oor %s', past: '%s gelede', s: "'n paar sekondes", m: "'n minuut", mm: '%d minute', h: "'n uur", hh: '%d ure', d: "'n dag", dd: '%d dae', M: "'n maand", MM: '%d maande', y: "'n jaar", yy: '%d jaar' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/am.js ================================================ // Amharic [am] import dayjs from 'dayjs' const locale = { name: 'am', weekdays: 'እሑድ_ሰኞ_ማክሰኞ_ረቡዕ_ሐሙስ_አርብ_ቅዳሜ'.split('_'), weekdaysShort: 'እሑድ_ሰኞ_ማክሰ_ረቡዕ_ሐሙስ_አርብ_ቅዳሜ'.split('_'), weekdaysMin: 'እሑ_ሰኞ_ማክ_ረቡ_ሐሙ_አር_ቅዳ'.split('_'), months: 'ጃንዋሪ_ፌብሯሪ_ማርች_ኤፕሪል_ሜይ_ጁን_ጁላይ_ኦገስት_ሴፕቴምበር_ኦክቶበር_ኖቬምበር_ዲሴምበር'.split('_'), monthsShort: 'ጃንዋ_ፌብሯ_ማርች_ኤፕሪ_ሜይ_ጁን_ጁላይ_ኦገስ_ሴፕቴ_ኦክቶ_ኖቬም_ዲሴም'.split('_'), weekStart: 1, yearStart: 4, relativeTime: { future: 'በ%s', past: '%s በፊት', s: 'ጥቂት ሰከንዶች', m: 'አንድ ደቂቃ', mm: '%d ደቂቃዎች', h: 'አንድ ሰዓት', hh: '%d ሰዓታት', d: 'አንድ ቀን', dd: '%d ቀናት', M: 'አንድ ወር', MM: '%d ወራት', y: 'አንድ ዓመት', yy: '%d ዓመታት' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'MMMM D ፣ YYYY', LLL: 'MMMM D ፣ YYYY HH:mm', LLLL: 'dddd ፣ MMMM D ፣ YYYY HH:mm' }, ordinal: n => `${n}ኛ` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-dz.js ================================================ // Arabic (Algeria) [ar-dz] import dayjs from 'dayjs' const locale = { name: 'ar-dz', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysShort: 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysMin: 'أح_إث_ثلا_أر_خم_جم_سب'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-iq.js ================================================ // Arabic (Iraq) [ar-iq] import dayjs from 'dayjs' const locale = { name: 'ar-iq', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول'.split('_'), weekStart: 1, weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-kw.js ================================================ // Arabic (Kuwait) [ar-kw] import dayjs from 'dayjs' const locale = { name: 'ar-kw', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), weekdaysShort: 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-ly.js ================================================ // Arabic (Lybia) [ar-ly] import dayjs from 'dayjs' const locale = { name: 'ar-ly', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekStart: 6, weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, meridiem: hour => (hour > 12 ? 'م' : 'ص'), formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'D/‏M/‏YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-ma.js ================================================ // Arabic (Morocco) [ar-ma] import dayjs from 'dayjs' const locale = { name: 'ar-ma', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), weekStart: 6, weekdaysShort: 'احد_إثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-sa.js ================================================ // Arabic (Saudi Arabia) [ar-sa] import dayjs from 'dayjs' const locale = { name: 'ar-sa', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar-tn.js ================================================ // Arabic (Tunisia) [ar-tn] import dayjs from 'dayjs' const locale = { name: 'ar-tn', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekStart: 1, weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'في %s', past: 'منذ %s', s: 'ثوان', m: 'دقيقة', mm: '%d دقائق', h: 'ساعة', hh: '%d ساعات', d: 'يوم', dd: '%d أيام', M: 'شهر', MM: '%d أشهر', y: 'سنة', yy: '%d سنوات' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ar.js ================================================ // Arabic [ar] import dayjs from 'dayjs' const months = 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_') const symbolMap = { 1: '١', 2: '٢', 3: '٣', 4: '٤', 5: '٥', 6: '٦', 7: '٧', 8: '٨', 9: '٩', 0: '٠' } const numberMap = { '١': '1', '٢': '2', '٣': '3', '٤': '4', '٥': '5', '٦': '6', '٧': '7', '٨': '8', '٩': '9', '٠': '0' } const fromArabNumeralsRegex = /[١٢٣٤٥٦٧٨٩٠]/g const fromArabComaRegex = /،/g const toArabNumeralsRegex = /\d/g const toArabComaRegex = /,/g const locale = { name: 'ar', weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), months, monthsShort: months, weekStart: 6, meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'بعد %s', past: 'منذ %s', s: 'ثانية واحدة', m: 'دقيقة واحدة', mm: '%d دقائق', h: 'ساعة واحدة', hh: '%d ساعات', d: 'يوم واحد', dd: '%d أيام', M: 'شهر واحد', MM: '%d أشهر', y: 'عام واحد', yy: '%d أعوام' }, preparse(string) { return string .replace( fromArabNumeralsRegex, match => numberMap[match] ) .replace(fromArabComaRegex, ',') }, postformat(string) { return string .replace(toArabNumeralsRegex, match => symbolMap[match]) .replace(toArabComaRegex, '،') }, ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'D/‏M/‏YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/az.js ================================================ // Azerbaijani [az] import dayjs from 'dayjs' const locale = { name: 'az', weekdays: 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'), weekdaysShort: 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'), weekdaysMin: 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'), months: 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'), monthsShort: 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY г.', LLL: 'D MMMM YYYY г., H:mm', LLLL: 'dddd, D MMMM YYYY г., H:mm' }, relativeTime: { future: '%s sonra', past: '%s əvvəl', s: 'bir neçə saniyə', m: 'bir dəqiqə', mm: '%d dəqiqə', h: 'bir saat', hh: '%d saat', d: 'bir gün', dd: '%d gün', M: 'bir ay', MM: '%d ay', y: 'bir il', yy: '%d il' }, ordinal: n => n } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/be.js ================================================ // Belarusian [be] import dayjs from 'dayjs' const monthFormat = 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_') const monthStandalone = 'студзень_лютый_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_') const monthShortFormat = 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж.'.split('_') const monthShortStandalone = 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_') const MONTHS_IN_FORMAT = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/ function plural(word, num) { const forms = word.split('_') return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]) // eslint-disable-line } function relativeTimeWithPlural(number, withoutSuffix, key) { const format = { ss: withoutSuffix ? 'секунда_секунды_секунд' : 'секунду_секунды_секунд', mm: withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін', hh: withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін', dd: 'дзень_дні_дзён', MM: 'месяц_месяцы_месяцаў', yy: 'год_гады_гадоў' } if (key === 'm') { return withoutSuffix ? 'хвіліна' : 'хвіліну' } else if (key === 'h') { return withoutSuffix ? 'гадзіна' : 'гадзіну' } return `${number} ${plural(format[key], +number)}` } const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const monthsShort = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthShortFormat[dayjsInstance.month()] } return monthShortStandalone[dayjsInstance.month()] } monthsShort.s = monthShortStandalone monthsShort.f = monthShortFormat const locale = { name: 'be', weekdays: 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'), weekdaysShort: 'няд_пнд_аўт_сер_чцв_пят_суб'.split('_'), weekdaysMin: 'нд_пн_аў_ср_чц_пт_сб'.split('_'), months, monthsShort, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY г.', LLL: 'D MMMM YYYY г., HH:mm', LLLL: 'dddd, D MMMM YYYY г., HH:mm' }, relativeTime: { future: 'праз %s', past: '%s таму', s: 'некалькі секунд', m: relativeTimeWithPlural, mm: relativeTimeWithPlural, h: relativeTimeWithPlural, hh: relativeTimeWithPlural, d: 'дзень', dd: relativeTimeWithPlural, M: 'месяц', MM: relativeTimeWithPlural, y: 'год', yy: relativeTimeWithPlural }, ordinal: n => n, meridiem: (hour) => { if (hour < 4) { return 'ночы' } else if (hour < 12) { return 'раніцы' } else if (hour < 17) { return 'дня' } return 'вечара' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bg.js ================================================ // Bulgarian [bg] import dayjs from 'dayjs' const locale = { name: 'bg', weekdays: 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'), weekdaysShort: 'нед_пон_вто_сря_чет_пет_съб'.split('_'), weekdaysMin: 'нд_пн_вт_ср_чт_пт_сб'.split('_'), months: 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'), monthsShort: 'яну_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'), weekStart: 1, ordinal: (n) => { const last2Digits = n % 100 if (last2Digits > 10 && last2Digits < 20) { return `${n}-ти` } const lastDigit = n % 10 if (lastDigit === 1) { return `${n}-ви` } else if (lastDigit === 2) { return `${n}-ри` } else if (lastDigit === 7 || lastDigit === 8) { return `${n}-ми` } return `${n}-ти` }, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'D.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY H:mm', LLLL: 'dddd, D MMMM YYYY H:mm' }, relativeTime: { future: 'след %s', past: 'преди %s', s: 'няколко секунди', m: 'минута', mm: '%d минути', h: 'час', hh: '%d часа', d: 'ден', dd: '%d дена', M: 'месец', MM: '%d месеца', y: 'година', yy: '%d години' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bi.js ================================================ // Bislama [bi] import dayjs from 'dayjs' const locale = { name: 'bi', weekdays: 'Sande_Mande_Tusde_Wenesde_Tosde_Fraede_Sarade'.split('_'), months: 'Januari_Februari_Maj_Eprel_Mei_Jun_Julae_Okis_Septemba_Oktoba_Novemba_Disemba'.split('_'), weekStart: 1, weekdaysShort: 'San_Man_Tus_Wen_Tos_Frae_Sar'.split('_'), monthsShort: 'Jan_Feb_Maj_Epr_Mai_Jun_Jul_Oki_Sep_Okt_Nov_Dis'.split('_'), weekdaysMin: 'San_Ma_Tu_We_To_Fr_Sar'.split('_'), ordinal: n => n, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: 'lo %s', past: '%s bifo', s: 'sam seken', m: 'wan minit', mm: '%d minit', h: 'wan haoa', hh: '%d haoa', d: 'wan dei', dd: '%d dei', M: 'wan manis', MM: '%d manis', y: 'wan yia', yy: '%d yia' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bm.js ================================================ // Bambara [bm] import dayjs from 'dayjs' const locale = { name: 'bm', weekdays: 'Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri'.split('_'), months: 'Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo'.split('_'), weekStart: 1, weekdaysShort: 'Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib'.split('_'), monthsShort: 'Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des'.split('_'), weekdaysMin: 'Ka_Nt_Ta_Ar_Al_Ju_Si'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'MMMM [tile] D [san] YYYY', LLL: 'MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm', LLLL: 'dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm' }, relativeTime: { future: '%s kɔnɔ', past: 'a bɛ %s bɔ', s: 'sanga dama dama', m: 'miniti kelen', mm: 'miniti %d', h: 'lɛrɛ kelen', hh: 'lɛrɛ %d', d: 'tile kelen', dd: 'tile %d', M: 'kalo kelen', MM: 'kalo %d', y: 'san kelen', yy: 'san %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bn-bd.js ================================================ // Bengali (Bangladesh) [bn-bd] import dayjs from 'dayjs' const symbolMap = { 1: '১', 2: '২', 3: '৩', 4: '৪', 5: '৫', 6: '৬', 7: '৭', 8: '৮', 9: '৯', 0: '০' } const numberMap = { '১': '1', '২': '2', '৩': '3', '৪': '4', '৫': '5', '৬': '6', '৭': '7', '৮': '8', '৯': '9', '০': '0' } const locale = { name: 'bn-bd', weekdays: 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'), months: 'জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), weekdaysShort: 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'), monthsShort: 'জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), weekdaysMin: 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'), weekStart: 0, preparse(string) { return string.replace(/[১২৩৪৫৬৭৮৯০]/g, match => numberMap[match]) }, postformat(string) { return string.replace(/\d/g, match => symbolMap[match]) }, ordinal: (n) => { const s = ['ই', 'লা', 'রা', 'ঠা', 'শে'] const v = n % 100 return `[${n}${s[(v - 20) % 10] || s[v] || s[0]}]` }, formats: { LT: 'A h:mm সময়', LTS: 'A h:mm:ss সময়', L: 'DD/MM/YYYY খ্রিস্টাব্দ', LL: 'D MMMM YYYY খ্রিস্টাব্দ', LLL: 'D MMMM YYYY খ্রিস্টাব্দ, A h:mm সময়', LLLL: 'dddd, D MMMM YYYY খ্রিস্টাব্দ, A h:mm সময়' }, meridiem: hour => /* eslint-disable no-nested-ternary */ (hour < 4 ? 'রাত' : hour < 6 ? 'ভোর' : hour < 12 ? 'সকাল' : hour < 15 ? 'দুপুর' : hour < 18 ? 'বিকাল' : hour < 20 ? 'সন্ধ্যা' : 'রাত'), relativeTime: { future: '%s পরে', past: '%s আগে', s: 'কয়েক সেকেন্ড', m: 'এক মিনিট', mm: '%d মিনিট', h: 'এক ঘন্টা', hh: '%d ঘন্টা', d: 'এক দিন', dd: '%d দিন', M: 'এক মাস', MM: '%d মাস', y: 'এক বছর', yy: '%d বছর' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bn.js ================================================ // Bengali [bn] import dayjs from 'dayjs' const symbolMap = { 1: '১', 2: '২', 3: '৩', 4: '৪', 5: '৫', 6: '৬', 7: '৭', 8: '৮', 9: '৯', 0: '০' } const numberMap = { '১': '1', '২': '2', '৩': '3', '৪': '4', '৫': '5', '৬': '6', '৭': '7', '৮': '8', '৯': '9', '০': '0' } const locale = { name: 'bn', weekdays: 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'), months: 'জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), weekdaysShort: 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'), monthsShort: 'জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), weekdaysMin: 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'), preparse(string) { return string.replace(/[১২৩৪৫৬৭৮৯০]/g, match => numberMap[match]) }, postformat(string) { return string.replace(/\d/g, match => symbolMap[match]) }, ordinal: n => n, formats: { LT: 'A h:mm সময়', LTS: 'A h:mm:ss সময়', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm সময়', LLLL: 'dddd, D MMMM YYYY, A h:mm সময়' }, relativeTime: { future: '%s পরে', past: '%s আগে', s: 'কয়েক সেকেন্ড', m: 'এক মিনিট', mm: '%d মিনিট', h: 'এক ঘন্টা', hh: '%d ঘন্টা', d: 'এক দিন', dd: '%d দিন', M: 'এক মাস', MM: '%d মাস', y: 'এক বছর', yy: '%d বছর' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bo.js ================================================ // Tibetan [bo] import dayjs from 'dayjs' const locale = { name: 'bo', weekdays: 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'), weekdaysShort: 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'), weekdaysMin: 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'), months: 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), monthsShort: 'ཟླ་དང་པོ_ཟླ་གཉིས་པ_ཟླ་གསུམ་པ_ཟླ་བཞི་པ_ཟླ་ལྔ་པ_ཟླ་དྲུག་པ_ཟླ་བདུན་པ_ཟླ་བརྒྱད་པ_ཟླ་དགུ་པ_ཟླ་བཅུ་པ_ཟླ་བཅུ་གཅིག་པ_ཟླ་བཅུ་གཉིས་པ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm', LTS: 'A h:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm', LLLL: 'dddd, D MMMM YYYY, A h:mm' }, relativeTime: { future: '%s ལ་', past: '%s སྔོན་ལ་', s: 'ཏོག་ཙམ་', m: 'སྐར་མ་གཅིག་', mm: 'སྐར་མ་ %d', h: 'ཆུ་ཚོད་གཅིག་', hh: 'ཆུ་ཚོད་ %d', d: 'ཉིན་གཅིག་', dd: 'ཉིན་ %d', M: 'ཟླ་བ་གཅིག་', MM: 'ཟླ་བ་ %d', y: 'ལོ་གཅིག་', yy: 'ལོ་ %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/br.js ================================================ // Breton [br] import dayjs from 'dayjs' function lastNumber(number) { if (number > 9) { return lastNumber(number % 10) } return number } function softMutation(text) { const mutationTable = { m: 'v', b: 'v', d: 'z' } return mutationTable[text.charAt(0)] + text.substring(1) } function mutation(text, number) { if (number === 2) { return softMutation(text) } return text } function relativeTimeWithMutation(number, withoutSuffix, key) { const format = { mm: 'munutenn', MM: 'miz', dd: 'devezh' } return `${number} ${mutation(format[key], number)}` } function specialMutationForYears(number) { /* istanbul ignore next line */ switch (lastNumber(number)) { case 1: case 3: case 4: case 5: case 9: return `${number} bloaz` default: return `${number} vloaz` } } const locale = { name: 'br', weekdays: 'Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn'.split('_'), months: 'Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'), weekStart: 1, weekdaysShort: 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'), monthsShort: 'Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'), weekdaysMin: 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'), ordinal: n => n, formats: { LT: 'h[e]mm A', LTS: 'h[e]mm:ss A', L: 'DD/MM/YYYY', LL: 'D [a viz] MMMM YYYY', LLL: 'D [a viz] MMMM YYYY h[e]mm A', LLLL: 'dddd, D [a viz] MMMM YYYY h[e]mm A' }, relativeTime: { future: 'a-benn %s', past: '%s ʼzo', s: 'un nebeud segondennoù', m: 'ur vunutenn', mm: relativeTimeWithMutation, h: 'un eur', hh: '%d eur', d: 'un devezh', dd: relativeTimeWithMutation, M: 'ur miz', MM: relativeTimeWithMutation, y: 'ur bloaz', yy: specialMutationForYears }, meridiem: hour => (hour < 12 ? 'a.m.' : 'g.m.') // a-raok merenn | goude merenn } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/bs.js ================================================ // Bosnian [bs] import dayjs from 'dayjs' const locale = { name: 'bs', weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'), months: 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'), weekStart: 1, weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'), monthsShort: 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'), weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), ordinal: n => n, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd, D. MMMM YYYY H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ca.js ================================================ // Catalan [ca] import dayjs from 'dayjs' const locale = { name: 'ca', weekdays: 'Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte'.split('_'), weekdaysShort: 'Dg._Dl._Dt._Dc._Dj._Dv._Ds.'.split('_'), weekdaysMin: 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'), months: 'Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre'.split('_'), monthsShort: 'Gen._Febr._Març_Abr._Maig_Juny_Jul._Ag._Set._Oct._Nov._Des.'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM [de] YYYY', LLL: 'D MMMM [de] YYYY [a les] H:mm', LLLL: 'dddd D MMMM [de] YYYY [a les] H:mm', ll: 'D MMM YYYY', lll: 'D MMM YYYY, H:mm', llll: 'ddd D MMM YYYY, H:mm' }, relativeTime: { future: 'd\'aquí %s', past: 'fa %s', s: 'uns segons', m: 'un minut', mm: '%d minuts', h: 'una hora', hh: '%d hores', d: 'un dia', dd: '%d dies', M: 'un mes', MM: '%d mesos', y: 'un any', yy: '%d anys' }, ordinal: (n) => { let ord if (n === 1 || n === 3) ord = 'r' else if (n === 2) ord = 'n' else if (n === 4) ord = 't' else ord = 'è' return `${n}${ord}` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/cs.js ================================================ // Czech [cs] import dayjs from 'dayjs' function plural(n) { return (n > 1) && (n < 5) && (~~(n / 10) !== 1) // eslint-disable-line } /* eslint-disable */ function translate(number, withoutSuffix, key, isFuture) { const result = `${number} ` switch (key) { case 's': // a few seconds / in a few seconds / a few seconds ago return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami' case 'm': // a minute / in a minute / a minute ago return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou') case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'minuty' : 'minut') } return `${result}minutami` case 'h': // an hour / in an hour / an hour ago return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou') case 'hh': // 9 hours / in 9 hours / 9 hours ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'hodiny' : 'hodin') } return `${result}hodinami` case 'd': // a day / in a day / a day ago return (withoutSuffix || isFuture) ? 'den' : 'dnem' case 'dd': // 9 days / in 9 days / 9 days ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'dny' : 'dní') } return `${result}dny` case 'M': // a month / in a month / a month ago return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem' case 'MM': // 9 months / in 9 months / 9 months ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'měsíce' : 'měsíců') } return `${result}měsíci` case 'y': // a year / in a year / a year ago return (withoutSuffix || isFuture) ? 'rok' : 'rokem' case 'yy': // 9 years / in 9 years / 9 years ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'roky' : 'let') } return `${result}lety` } } /* eslint-enable */ const locale = { name: 'cs', weekdays: 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'), weekdaysShort: 'ne_po_út_st_čt_pá_so'.split('_'), weekdaysMin: 'ne_po_út_st_čt_pá_so'.split('_'), months: 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'), monthsShort: 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_'), weekStart: 1, yearStart: 4, ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd D. MMMM YYYY H:mm', l: 'D. M. YYYY' }, relativeTime: { future: 'za %s', past: 'před %s', s: translate, m: translate, mm: translate, h: translate, hh: translate, d: translate, dd: translate, M: translate, MM: translate, y: translate, yy: translate } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/cv.js ================================================ // Chuvash [cv] import dayjs from 'dayjs' const locale = { name: 'cv', weekdays: 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'), months: 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'), weekStart: 1, weekdaysShort: 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'), monthsShort: 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'), weekdaysMin: 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD-MM-YYYY', LL: 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]', LLL: 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm', LLLL: 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/cy.js ================================================ // Welsh [cy] import dayjs from 'dayjs' const locale = { name: 'cy', weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'), months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'), weekStart: 1, weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'), monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'), weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'mewn %s', past: '%s yn ôl', s: 'ychydig eiliadau', m: 'munud', mm: '%d munud', h: 'awr', hh: '%d awr', d: 'diwrnod', dd: '%d diwrnod', M: 'mis', MM: '%d mis', y: 'blwyddyn', yy: '%d flynedd' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/da.js ================================================ // Danish [da] import dayjs from 'dayjs' const locale = { name: 'da', weekdays: 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'), weekdaysShort: 'søn._man._tirs._ons._tors._fre._lør.'.split('_'), weekdaysMin: 'sø._ma._ti._on._to._fr._lø.'.split('_'), months: 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'), monthsShort: 'jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.'.split('_'), weekStart: 1, yearStart: 4, ordinal: n => `${n}.`, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY HH:mm', LLLL: 'dddd [d.] D. MMMM YYYY [kl.] HH:mm' }, relativeTime: { future: 'om %s', past: '%s siden', s: 'få sekunder', m: 'et minut', mm: '%d minutter', h: 'en time', hh: '%d timer', d: 'en dag', dd: '%d dage', M: 'en måned', MM: '%d måneder', y: 'et år', yy: '%d år' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/de-at.js ================================================ // German (Austria) [de-at] import dayjs from 'dayjs' const texts = { s: 'ein paar Sekunden', m: ['eine Minute', 'einer Minute'], mm: '%d Minuten', h: ['eine Stunde', 'einer Stunde'], hh: '%d Stunden', d: ['ein Tag', 'einem Tag'], dd: ['%d Tage', '%d Tagen'], M: ['ein Monat', 'einem Monat'], MM: ['%d Monate', '%d Monaten'], y: ['ein Jahr', 'einem Jahr'], yy: ['%d Jahre', '%d Jahren'] } function relativeTimeFormatter(number, withoutSuffix, key) { let l = texts[key] if (Array.isArray(l)) { l = l[withoutSuffix ? 0 : 1] } return l.replace('%d', number) } const locale = { name: 'de-at', weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'), weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), months: 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), monthsShort: 'Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'), ordinal: n => `${n}.`, weekStart: 1, formats: { LTS: 'HH:mm:ss', LT: 'HH:mm', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY HH:mm', LLLL: 'dddd, D. MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: 'vor %s', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/de-ch.js ================================================ // German (Switzerland) [de-ch] import dayjs from 'dayjs' const texts = { s: 'ein paar Sekunden', m: ['eine Minute', 'einer Minute'], mm: '%d Minuten', h: ['eine Stunde', 'einer Stunde'], hh: '%d Stunden', d: ['ein Tag', 'einem Tag'], dd: ['%d Tage', '%d Tagen'], M: ['ein Monat', 'einem Monat'], MM: ['%d Monate', '%d Monaten'], y: ['ein Jahr', 'einem Jahr'], yy: ['%d Jahre', '%d Jahren'] } function relativeTimeFormatter(number, withoutSuffix, key) { let l = texts[key] if (Array.isArray(l)) { l = l[withoutSuffix ? 0 : 1] } return l.replace('%d', number) } const locale = { name: 'de-ch', weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), weekdaysShort: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'), ordinal: n => `${n}.`, weekStart: 1, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY HH:mm', LLLL: 'dddd, D. MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: 'vor %s', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/de.js ================================================ // German [de] import dayjs from 'dayjs' const texts = { s: 'ein paar Sekunden', m: ['eine Minute', 'einer Minute'], mm: '%d Minuten', h: ['eine Stunde', 'einer Stunde'], hh: '%d Stunden', d: ['ein Tag', 'einem Tag'], dd: ['%d Tage', '%d Tagen'], M: ['ein Monat', 'einem Monat'], MM: ['%d Monate', '%d Monaten'], y: ['ein Jahr', 'einem Jahr'], yy: ['%d Jahre', '%d Jahren'] } function relativeTimeFormatter(number, withoutSuffix, key) { let l = texts[key] if (Array.isArray(l)) { l = l[withoutSuffix ? 0 : 1] } return l.replace('%d', number) } const locale = { name: 'de', weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'), weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.'.split('_'), ordinal: n => `${n}.`, weekStart: 1, yearStart: 4, formats: { LTS: 'HH:mm:ss', LT: 'HH:mm', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY HH:mm', LLLL: 'dddd, D. MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: 'vor %s', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/dv.js ================================================ // Maldivian [dv] import dayjs from 'dayjs' const locale = { name: 'dv', weekdays: 'އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު'.split('_'), months: 'ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު'.split('_'), weekStart: 7, weekdaysShort: 'އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު'.split('_'), monthsShort: 'ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު'.split('_'), weekdaysMin: 'އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'D/M/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'ތެރޭގައި %s', past: 'ކުރިން %s', s: 'ސިކުންތުކޮޅެއް', m: 'މިނިޓެއް', mm: 'މިނިޓު %d', h: 'ގަޑިއިރެއް', hh: 'ގަޑިއިރު %d', d: 'ދުވަހެއް', dd: 'ދުވަސް %d', M: 'މަހެއް', MM: 'މަސް %d', y: 'އަހަރެއް', yy: 'އަހަރު %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/el.js ================================================ // Greek [el] import dayjs from 'dayjs' const locale = { name: 'el', weekdays: 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'), weekdaysShort: 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'), weekdaysMin: 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'), months: 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'), monthsShort: 'Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ'.split('_'), ordinal: n => n, weekStart: 1, relativeTime: { future: 'σε %s', past: 'πριν %s', s: 'μερικά δευτερόλεπτα', m: 'ένα λεπτό', mm: '%d λεπτά', h: 'μία ώρα', hh: '%d ώρες', d: 'μία μέρα', dd: '%d μέρες', M: 'ένα μήνα', MM: '%d μήνες', y: 'ένα χρόνο', yy: '%d χρόνια' }, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-au.js ================================================ // English (Australia) [en-au] import dayjs from 'dayjs' const locale = { name: 'en-au', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekStart: 1, weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' }, ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-ca.js ================================================ // English (Canada) [en-ca] import dayjs from 'dayjs' const locale = { name: 'en-ca', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'YYYY-MM-DD', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', LLLL: 'dddd, MMMM D, YYYY h:mm A' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-gb.js ================================================ // English (United Kingdom) [en-gb] import dayjs from 'dayjs' const locale = { name: 'en-gb', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekStart: 1, yearStart: 4, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-ie.js ================================================ // English (Ireland) [en-ie] import dayjs from 'dayjs' const locale = { name: 'en-ie', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekStart: 1, weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-il.js ================================================ // English (Israel) [en-il] import dayjs from 'dayjs' const locale = { name: 'en-il', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-in.js ================================================ // English (India) [en-in] import dayjs from 'dayjs' const locale = { name: 'en-in', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekStart: 1, yearStart: 4, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-nz.js ================================================ // English (New Zealand) [en-nz] import dayjs from 'dayjs' const locale = { name: 'en-nz', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekStart: 1, weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${s[(v - 20) % 10] || s[v] || s[0]}]` }, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-sg.js ================================================ // English (Singapore) [en-sg] import dayjs from 'dayjs' const locale = { name: 'en-sg', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), weekStart: 1, weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en-tt.js ================================================ // English (Trinidad & Tobago) [en-tt] import dayjs from 'dayjs' const locale = { name: 'en-tt', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), weekStart: 1, yearStart: 4, relativeTime: { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/en.js ================================================ // English [en] // We don't need weekdaysShort, weekdaysMin, monthsShort in en.js locale export default { name: 'en', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), ordinal: (n) => { const s = ['th', 'st', 'nd', 'rd'] const v = n % 100 return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]` } } ================================================ FILE: src/locale/eo.js ================================================ // Esperanto [eo] import dayjs from 'dayjs' const locale = { name: 'eo', weekdays: 'dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato'.split('_'), months: 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'), weekStart: 1, weekdaysShort: 'dim_lun_mard_merk_ĵaŭ_ven_sab'.split('_'), monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'), weekdaysMin: 'di_lu_ma_me_ĵa_ve_sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'D[-a de] MMMM, YYYY', LLL: 'D[-a de] MMMM, YYYY HH:mm', LLLL: 'dddd, [la] D[-a de] MMMM, YYYY HH:mm' }, relativeTime: { future: 'post %s', past: 'antaŭ %s', s: 'sekundoj', m: 'minuto', mm: '%d minutoj', h: 'horo', hh: '%d horoj', d: 'tago', dd: '%d tagoj', M: 'monato', MM: '%d monatoj', y: 'jaro', yy: '%d jaroj' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/es-do.js ================================================ // Spanish (Dominican Republic) [es-do] import dayjs from 'dayjs' const locale = { name: 'es-do', weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), weekStart: 1, relativeTime: { future: 'en %s', past: 'hace %s', s: 'unos segundos', m: 'un minuto', mm: '%d minutos', h: 'una hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un año', yy: '%d años' }, ordinal: n => `${n}º`, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY h:mm A', LLLL: 'dddd, D [de] MMMM [de] YYYY h:mm A' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/es-mx.js ================================================ // Spanish (Mexico) [es-mx] import dayjs from 'dayjs' const locale = { name: 'es-mx', weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), relativeTime: { future: 'en %s', past: 'hace %s', s: 'unos segundos', m: 'un minuto', mm: '%d minutos', h: 'una hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un año', yy: '%d años' }, ordinal: n => `${n}º`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY H:mm', LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/es-pr.js ================================================ // Spanish (Puerto Rico) [es-PR] import dayjs from 'dayjs' const locale = { name: 'es-pr', monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), weekStart: 1, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'MM/DD/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY h:mm A', LLLL: 'dddd, D [de] MMMM [de] YYYY h:mm A' }, relativeTime: { future: 'en %s', past: 'hace %s', s: 'unos segundos', m: 'un minuto', mm: '%d minutos', h: 'una hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un año', yy: '%d años' }, ordinal: n => `${n}º` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/es-us.js ================================================ // Spanish (United States) [es-us] import dayjs from 'dayjs' const locale = { name: 'es-us', weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), relativeTime: { future: 'en %s', past: 'hace %s', s: 'unos segundos', m: 'un minuto', mm: '%d minutos', h: 'una hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un año', yy: '%d años' }, ordinal: n => `${n}º`, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'MM/DD/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY h:mm A', LLLL: 'dddd, D [de] MMMM [de] YYYY h:mm A' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/es.js ================================================ // Spanish [es] import dayjs from 'dayjs' const locale = { name: 'es', monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY H:mm', LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm' }, relativeTime: { future: 'en %s', past: 'hace %s', s: 'unos segundos', m: 'un minuto', mm: '%d minutos', h: 'una hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un año', yy: '%d años' }, ordinal: n => `${n}º` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/et.js ================================================ // Estonian [et] import dayjs from 'dayjs' function relativeTimeWithTense(number, withoutSuffix, key, isFuture) { const format = { s: ['mõne sekundi', 'mõni sekund', 'paar sekundit'], m: ['ühe minuti', 'üks minut'], mm: ['%d minuti', '%d minutit'], h: ['ühe tunni', 'tund aega', 'üks tund'], hh: ['%d tunni', '%d tundi'], d: ['ühe päeva', 'üks päev'], M: ['kuu aja', 'kuu aega', 'üks kuu'], MM: ['%d kuu', '%d kuud'], y: ['ühe aasta', 'aasta', 'üks aasta'], yy: ['%d aasta', '%d aastat'] } if (withoutSuffix) { return (format[key][2] ? format[key][2] : format[key][1]).replace('%d', number) } return (isFuture ? format[key][0] : format[key][1]).replace('%d', number) } const locale = { name: 'et', // Estonian weekdays: 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'), // Note weekdays are not capitalized in Estonian weekdaysShort: 'P_E_T_K_N_R_L'.split('_'), // There is no short form of weekdays in Estonian except this 1 letter format so it is used for both 'weekdaysShort' and 'weekdaysMin' weekdaysMin: 'P_E_T_K_N_R_L'.split('_'), months: 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'), // Note month names are not capitalized in Estonian monthsShort: 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'), ordinal: n => `${n}.`, weekStart: 1, relativeTime: { future: '%s pärast', past: '%s tagasi', s: relativeTimeWithTense, m: relativeTimeWithTense, mm: relativeTimeWithTense, h: relativeTimeWithTense, hh: relativeTimeWithTense, d: relativeTimeWithTense, dd: '%d päeva', M: relativeTimeWithTense, MM: relativeTimeWithTense, y: relativeTimeWithTense, yy: relativeTimeWithTense }, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd, D. MMMM YYYY H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/eu.js ================================================ // Basque [eu] import dayjs from 'dayjs' const locale = { name: 'eu', weekdays: 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'), months: 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'), weekStart: 1, weekdaysShort: 'ig._al._ar._az._og._ol._lr.'.split('_'), monthsShort: 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'), weekdaysMin: 'ig_al_ar_az_og_ol_lr'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'YYYY[ko] MMMM[ren] D[a]', LLL: 'YYYY[ko] MMMM[ren] D[a] HH:mm', LLLL: 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm', l: 'YYYY-M-D', ll: 'YYYY[ko] MMM D[a]', lll: 'YYYY[ko] MMM D[a] HH:mm', llll: 'ddd, YYYY[ko] MMM D[a] HH:mm' }, relativeTime: { future: '%s barru', past: 'duela %s', s: 'segundo batzuk', m: 'minutu bat', mm: '%d minutu', h: 'ordu bat', hh: '%d ordu', d: 'egun bat', dd: '%d egun', M: 'hilabete bat', MM: '%d hilabete', y: 'urte bat', yy: '%d urte' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fa.js ================================================ // Persian [fa] import dayjs from 'dayjs' const locale = { name: 'fa', weekdays: 'یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه'.split('_'), weekdaysShort: 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'), weekdaysMin: 'ی_د_س_چ_پ_ج_ش'.split('_'), weekStart: 6, months: 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'), monthsShort: 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'در %s', past: '%s پیش', s: 'چند ثانیه', m: 'یک دقیقه', mm: '%d دقیقه', h: 'یک ساعت', hh: '%d ساعت', d: 'یک روز', dd: '%d روز', M: 'یک ماه', MM: '%d ماه', y: 'یک سال', yy: '%d سال' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fi.js ================================================ // Finnish [fi] import dayjs from 'dayjs' function relativeTimeFormatter(number, withoutSuffix, key, isFuture) { const past = { s: 'muutama sekunti', m: 'minuutti', mm: '%d minuuttia', h: 'tunti', hh: '%d tuntia', d: 'päivä', dd: '%d päivää', M: 'kuukausi', MM: '%d kuukautta', y: 'vuosi', yy: '%d vuotta', numbers: 'nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän'.split('_') } const future = { s: 'muutaman sekunnin', m: 'minuutin', mm: '%d minuutin', h: 'tunnin', hh: '%d tunnin', d: 'päivän', dd: '%d päivän', M: 'kuukauden', MM: '%d kuukauden', y: 'vuoden', yy: '%d vuoden', numbers: 'nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän'.split('_') } const words = (isFuture && !withoutSuffix) ? future : past const result = words[key] if (number < 10) { return result.replace('%d', words.numbers[number]) } return result.replace('%d', number) } const locale = { name: 'fi', // Finnish weekdays: 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'), // Note weekdays are not capitalized in Finnish weekdaysShort: 'su_ma_ti_ke_to_pe_la'.split('_'), // There is no short form of weekdays in Finnish except this 2 letter format so it is used for both 'weekdaysShort' and 'weekdaysMin' weekdaysMin: 'su_ma_ti_ke_to_pe_la'.split('_'), months: 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'), // Note month names are not capitalized in Finnish monthsShort: 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'), ordinal: n => `${n}.`, weekStart: 1, yearStart: 4, relativeTime: { future: '%s päästä', past: '%s sitten', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter }, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD.MM.YYYY', LL: 'D. MMMM[ta] YYYY', LLL: 'D. MMMM[ta] YYYY, [klo] HH.mm', LLLL: 'dddd, D. MMMM[ta] YYYY, [klo] HH.mm', l: 'D.M.YYYY', ll: 'D. MMM YYYY', lll: 'D. MMM YYYY, [klo] HH.mm', llll: 'ddd, D. MMM YYYY, [klo] HH.mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fo.js ================================================ // Faroese [fo] import dayjs from 'dayjs' const locale = { name: 'fo', weekdays: 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'), months: 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'), weekStart: 1, weekdaysShort: 'sun_mán_týs_mik_hós_frí_ley'.split('_'), monthsShort: 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'), weekdaysMin: 'su_má_tý_mi_hó_fr_le'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D. MMMM, YYYY HH:mm' }, relativeTime: { future: 'um %s', past: '%s síðani', s: 'fá sekund', m: 'ein minuttur', mm: '%d minuttir', h: 'ein tími', hh: '%d tímar', d: 'ein dagur', dd: '%d dagar', M: 'ein mánaður', MM: '%d mánaðir', y: 'eitt ár', yy: '%d ár' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fr-ca.js ================================================ // French (Canada) [fr-ca] import dayjs from 'dayjs' const locale = { name: 'fr-ca', weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'dans %s', past: 'il y a %s', s: 'quelques secondes', m: 'une minute', mm: '%d minutes', h: 'une heure', hh: '%d heures', d: 'un jour', dd: '%d jours', M: 'un mois', MM: '%d mois', y: 'un an', yy: '%d ans' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fr-ch.js ================================================ // French (Switzerland) [fr-ch] import dayjs from 'dayjs' const locale = { name: 'fr-ch', weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), weekStart: 1, weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'dans %s', past: 'il y a %s', s: 'quelques secondes', m: 'une minute', mm: '%d minutes', h: 'une heure', hh: '%d heures', d: 'un jour', dd: '%d jours', M: 'un mois', MM: '%d mois', y: 'un an', yy: '%d ans' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fr.js ================================================ // French [fr] import dayjs from 'dayjs' const locale = { name: 'fr', weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'dans %s', past: 'il y a %s', s: 'quelques secondes', m: 'une minute', mm: '%d minutes', h: 'une heure', hh: '%d heures', d: 'un jour', dd: '%d jours', M: 'un mois', MM: '%d mois', y: 'un an', yy: '%d ans' }, ordinal: (n) => { const o = n === 1 ? 'er' : '' return `${n}${o}` } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/fy.js ================================================ // Frisian [fy] import dayjs from 'dayjs' const locale = { name: 'fy', weekdays: 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'), months: 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'), monthsShort: 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_'), weekStart: 1, weekdaysShort: 'si._mo._ti._wo._to._fr._so.'.split('_'), weekdaysMin: 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD-MM-YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'oer %s', past: '%s lyn', s: 'in pear sekonden', m: 'ien minút', mm: '%d minuten', h: 'ien oere', hh: '%d oeren', d: 'ien dei', dd: '%d dagen', M: 'ien moanne', MM: '%d moannen', y: 'ien jier', yy: '%d jierren' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ga.js ================================================ // Irish or Irish Gaelic [ga] import dayjs from 'dayjs' const locale = { name: 'ga', weekdays: 'Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Sathairn'.split('_'), months: 'Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Meitheamh_Iúil_Lúnasa_Meán Fómhair_Deireadh Fómhair_Samhain_Nollaig'.split('_'), weekStart: 1, weekdaysShort: 'Dom_Lua_Mái_Céa_Déa_Aoi_Sat'.split('_'), monthsShort: 'Ean_Fea_Már_Aib_Beal_Mei_Iúil_Lún_MFómh_DFómh_Samh_Noll'.split('_'), weekdaysMin: 'Do_Lu_Má_Cé_Dé_Ao_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'i %s', past: '%s ó shin', s: 'cúpla soicind', m: 'nóiméad', mm: '%d nóiméad', h: 'uair an chloig', hh: '%d uair an chloig', d: 'lá', dd: '%d lá', M: 'mí', MM: '%d mí', y: 'bliain', yy: '%d bliain' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/gd.js ================================================ // Scottish Gaelic [gd] import dayjs from 'dayjs' const locale = { name: 'gd', weekdays: 'Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne'.split('_'), months: 'Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd'.split('_'), weekStart: 1, weekdaysShort: 'Did_Dil_Dim_Dic_Dia_Dih_Dis'.split('_'), monthsShort: 'Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh'.split('_'), weekdaysMin: 'Dò_Lu_Mà_Ci_Ar_Ha_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'ann an %s', past: 'bho chionn %s', s: 'beagan diogan', m: 'mionaid', mm: '%d mionaidean', h: 'uair', hh: '%d uairean', d: 'latha', dd: '%d latha', M: 'mìos', MM: '%d mìosan', y: 'bliadhna', yy: '%d bliadhna' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/gl.js ================================================ // Galician [gl] import dayjs from 'dayjs' const locale = { name: 'gl', weekdays: 'domingo_luns_martes_mércores_xoves_venres_sábado'.split('_'), months: 'xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro'.split('_'), weekStart: 1, weekdaysShort: 'dom._lun._mar._mér._xov._ven._sáb.'.split('_'), monthsShort: 'xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.'.split('_'), weekdaysMin: 'do_lu_ma_mé_xo_ve_sá'.split('_'), ordinal: n => `${n}º`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY H:mm', LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm' }, relativeTime: { future: 'en %s', past: 'fai %s', s: 'uns segundos', m: 'un minuto', mm: '%d minutos', h: 'unha hora', hh: '%d horas', d: 'un día', dd: '%d días', M: 'un mes', MM: '%d meses', y: 'un ano', yy: '%d anos' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/gom-latn.js ================================================ // Konkani Latin script [gom-latn] import dayjs from 'dayjs' const locale = { name: 'gom-latn', weekdays: "Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split('_'), months: 'Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr'.split('_'), weekStart: 1, weekdaysShort: 'Ait._Som._Mon._Bud._Bre._Suk._Son.'.split('_'), monthsShort: 'Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.'.split('_'), weekdaysMin: 'Ai_Sm_Mo_Bu_Br_Su_Sn'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm [vazta]', LTS: 'A h:mm:ss [vazta]', L: 'DD-MM-YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY A h:mm [vazta]', LLLL: 'dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]', llll: 'ddd, D MMM YYYY, A h:mm [vazta]' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/gu.js ================================================ // Gujarati [gu] import dayjs from 'dayjs' const locale = { name: 'gu', weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split('_'), months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split('_'), weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'), monthsShort: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split('_'), weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm વાગ્યે', LTS: 'A h:mm:ss વાગ્યે', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm વાગ્યે', LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે' }, relativeTime: { future: '%s મા', past: '%s પેહલા', s: 'અમુક પળો', m: 'એક મિનિટ', mm: '%d મિનિટ', h: 'એક કલાક', hh: '%d કલાક', d: 'એક દિવસ', dd: '%d દિવસ', M: 'એક મહિનો', MM: '%d મહિનો', y: 'એક વર્ષ', yy: '%d વર્ષ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/he.js ================================================ // Hebrew [he] import dayjs from 'dayjs' const texts = { s: 'מספר שניות', ss: '%d שניות', m: 'דקה', mm: '%d דקות', h: 'שעה', hh: '%d שעות', hh2: 'שעתיים', d: 'יום', dd: '%d ימים', dd2: 'יומיים', M: 'חודש', MM: '%d חודשים', MM2: 'חודשיים', y: 'שנה', yy: '%d שנים', yy2: 'שנתיים' } function relativeTimeFormatter(number, withoutSuffix, key) { const text = texts[key + (number === 2 ? '2' : '')] || texts[key] return text.replace('%d', number) } const locale = { name: 'he', weekdays: 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'), weekdaysShort: 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'), weekdaysMin: 'א׳_ב׳_ג׳_ד׳_ה׳_ו_ש׳'.split('_'), months: 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'), monthsShort: 'ינו_פבר_מרץ_אפר_מאי_יונ_יול_אוג_ספט_אוק_נוב_דצמ'.split('_'), relativeTime: { future: 'בעוד %s', past: 'לפני %s', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter }, ordinal: n => n, format: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D [ב]MMMM YYYY', LLL: 'D [ב]MMMM YYYY HH:mm', LLLL: 'dddd, D [ב]MMMM YYYY HH:mm', l: 'D/M/YYYY', ll: 'D MMM YYYY', lll: 'D MMM YYYY HH:mm', llll: 'ddd, D MMM YYYY HH:mm' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D [ב]MMMM YYYY', LLL: 'D [ב]MMMM YYYY HH:mm', LLLL: 'dddd, D [ב]MMMM YYYY HH:mm', l: 'D/M/YYYY', ll: 'D MMM YYYY', lll: 'D MMM YYYY HH:mm', llll: 'ddd, D MMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/hi.js ================================================ // Hindi [hi] import dayjs from 'dayjs' const locale = { name: 'hi', weekdays: 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), months: 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'), weekdaysShort: 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'), monthsShort: 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'), weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm बजे', LTS: 'A h:mm:ss बजे', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm बजे', LLLL: 'dddd, D MMMM YYYY, A h:mm बजे' }, relativeTime: { future: '%s में', past: '%s पहले', s: 'कुछ ही क्षण', m: 'एक मिनट', mm: '%d मिनट', h: 'एक घंटा', hh: '%d घंटे', d: 'एक दिन', dd: '%d दिन', M: 'एक महीने', MM: '%d महीने', y: 'एक वर्ष', yy: '%d वर्ष' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/hr.js ================================================ // Croatian [hr] import dayjs from 'dayjs' const monthFormat = 'siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca'.split('_') const monthStandalone = 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_') const MONTHS_IN_FORMAT = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/ const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const locale = { name: 'hr', weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'), weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'), weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), months, monthsShort: 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd, D. MMMM YYYY H:mm' }, relativeTime: { future: 'za %s', past: 'prije %s', s: 'sekunda', m: 'minuta', mm: '%d minuta', h: 'sat', hh: '%d sati', d: 'dan', dd: '%d dana', M: 'mjesec', MM: '%d mjeseci', y: 'godina', yy: '%d godine' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ht.js ================================================ // Haitian Creole (Haiti) [ht] import dayjs from 'dayjs' const locale = { name: 'ht', weekdays: 'dimanch_lendi_madi_mèkredi_jedi_vandredi_samdi'.split('_'), months: 'janvye_fevriye_mas_avril_me_jen_jiyè_out_septanm_oktòb_novanm_desanm'.split('_'), weekdaysShort: 'dim._len._mad._mèk._jed._van._sam.'.split('_'), monthsShort: 'jan._fev._mas_avr._me_jen_jiyè._out_sept._okt._nov._des.'.split('_'), weekdaysMin: 'di_le_ma_mè_je_va_sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'nan %s', past: 'sa gen %s', s: 'kèk segond', m: 'yon minit', mm: '%d minit', h: 'inèdtan', hh: '%d zè', d: 'yon jou', dd: '%d jou', M: 'yon mwa', MM: '%d mwa', y: 'yon ane', yy: '%d ane' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/hu.js ================================================ // Hungarian [hu] import dayjs from 'dayjs' const locale = { name: 'hu', weekdays: 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'), weekdaysShort: 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'), weekdaysMin: 'v_h_k_sze_cs_p_szo'.split('_'), months: 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'), monthsShort: 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'), ordinal: n => `${n}.`, weekStart: 1, relativeTime: { future: '%s múlva', past: '%s', s: (_, s, ___, isFuture) => `néhány másodperc${isFuture || s ? '' : 'e'}`, m: (_, s, ___, isFuture) => `egy perc${isFuture || s ? '' : 'e'}`, mm: (n, s, ___, isFuture) => `${n} perc${isFuture || s ? '' : 'e'}`, h: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'óra' : 'órája'}`, hh: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'óra' : 'órája'}`, d: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'nap' : 'napja'}`, dd: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'nap' : 'napja'}`, M: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'hónap' : 'hónapja'}`, MM: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'hónap' : 'hónapja'}`, y: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'év' : 'éve'}`, yy: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'év' : 'éve'}` }, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'YYYY.MM.DD.', LL: 'YYYY. MMMM D.', LLL: 'YYYY. MMMM D. H:mm', LLLL: 'YYYY. MMMM D., dddd H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/hy-am.js ================================================ // Armenian [hy-am] import dayjs from 'dayjs' const locale = { name: 'hy-am', weekdays: 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_'), months: 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_'), weekStart: 1, weekdaysShort: 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'), monthsShort: 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'), weekdaysMin: 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY թ.', LLL: 'D MMMM YYYY թ., HH:mm', LLLL: 'dddd, D MMMM YYYY թ., HH:mm' }, relativeTime: { future: '%s հետո', past: '%s առաջ', s: 'մի քանի վայրկյան', m: 'րոպե', mm: '%d րոպե', h: 'ժամ', hh: '%d ժամ', d: 'օր', dd: '%d օր', M: 'ամիս', MM: '%d ամիս', y: 'տարի', yy: '%d տարի' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/id.js ================================================ // Indonesian [id] import dayjs from 'dayjs' const locale = { name: 'id', weekdays: 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'), months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'), weekdaysShort: 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des'.split('_'), weekdaysMin: 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'), weekStart: 1, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [pukul] HH.mm', LLLL: 'dddd, D MMMM YYYY [pukul] HH.mm' }, relativeTime: { future: 'dalam %s', past: '%s yang lalu', s: 'beberapa detik', m: 'semenit', mm: '%d menit', h: 'sejam', hh: '%d jam', d: 'sehari', dd: '%d hari', M: 'sebulan', MM: '%d bulan', y: 'setahun', yy: '%d tahun' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/is.js ================================================ // Icelandic [is] import dayjs from 'dayjs' const texts = { s: ['nokkrar sekúndur', 'nokkrar sekúndur', 'nokkrum sekúndum'], m: ['mínúta', 'mínútu', 'mínútu'], mm: ['mínútur', 'mínútur', 'mínútum'], h: ['klukkustund', 'klukkustund', 'klukkustund'], hh: ['klukkustundir', 'klukkustundir', 'klukkustundum'], d: ['dagur', 'dag', 'degi'], dd: ['dagar', 'daga', 'dögum'], M: ['mánuður', 'mánuð', 'mánuði'], MM: ['mánuðir', 'mánuði', 'mánuðum'], y: ['ár', 'ár', 'ári'], yy: ['ár', 'ár', 'árum'] } function resolveTemplate(key, number, isFuture, withoutSuffix) { const suffixIndex = isFuture ? 1 : 2 const index = withoutSuffix ? 0 : suffixIndex const keyShouldBeSingular = key.length === 2 && number % 10 === 1 const correctedKey = keyShouldBeSingular ? key[0] : key const unitText = texts[correctedKey] const text = unitText[index] return key.length === 1 ? text : `%d ${text}` } function relativeTimeFormatter(number, withoutSuffix, key, isFuture) { const template = resolveTemplate(key, number, isFuture, withoutSuffix) return template.replace('%d', number) } const locale = { name: 'is', weekdays: 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'), months: 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'), weekStart: 1, weekdaysShort: 'sun_mán_þri_mið_fim_fös_lau'.split('_'), monthsShort: 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'), weekdaysMin: 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'), ordinal: n => n, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY [kl.] H:mm', LLLL: 'dddd, D. MMMM YYYY [kl.] H:mm' }, relativeTime: { future: 'eftir %s', past: 'fyrir %s síðan', s: relativeTimeFormatter, m: relativeTimeFormatter, mm: relativeTimeFormatter, h: relativeTimeFormatter, hh: relativeTimeFormatter, d: relativeTimeFormatter, dd: relativeTimeFormatter, M: relativeTimeFormatter, MM: relativeTimeFormatter, y: relativeTimeFormatter, yy: relativeTimeFormatter } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/it-ch.js ================================================ // Italian (Switzerland) [it-ch] import dayjs from 'dayjs' const locale = { name: 'it-ch', weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'), months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'), weekStart: 1, weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'), monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'), weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'tra %s', past: '%s fa', s: 'alcuni secondi', m: 'un minuto', mm: '%d minuti', h: 'un\'ora', hh: '%d ore', d: 'un giorno', dd: '%d giorni', M: 'un mese', MM: '%d mesi', y: 'un anno', yy: '%d anni' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/it.js ================================================ // Italian [it] import dayjs from 'dayjs' const locale = { name: 'it', weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'), weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'), weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'), months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'), weekStart: 1, monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'), formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'tra %s', past: '%s fa', s: 'qualche secondo', m: 'un minuto', mm: '%d minuti', h: 'un\'ora', hh: '%d ore', d: 'un giorno', dd: '%d giorni', M: 'un mese', MM: '%d mesi', y: 'un anno', yy: '%d anni' }, ordinal: n => `${n}º` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ja.js ================================================ // Japanese [ja] import dayjs from 'dayjs' const locale = { name: 'ja', weekdays: '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'), weekdaysShort: '日_月_火_水_木_金_土'.split('_'), weekdaysMin: '日_月_火_水_木_金_土'.split('_'), months: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), ordinal: n => `${n}日`, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', LLLL: 'YYYY年M月D日 dddd HH:mm', l: 'YYYY/MM/DD', ll: 'YYYY年M月D日', lll: 'YYYY年M月D日 HH:mm', llll: 'YYYY年M月D日(ddd) HH:mm' }, meridiem: hour => (hour < 12 ? '午前' : '午後'), relativeTime: { future: '%s後', past: '%s前', s: '数秒', m: '1分', mm: '%d分', h: '1時間', hh: '%d時間', d: '1日', dd: '%d日', M: '1ヶ月', MM: '%dヶ月', y: '1年', yy: '%d年' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/jv.js ================================================ // Javanese [jv] import dayjs from 'dayjs' const locale = { name: 'jv', weekdays: 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'), months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'), weekStart: 1, weekdaysShort: 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'), monthsShort: 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'), weekdaysMin: 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'), ordinal: n => n, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [pukul] HH.mm', LLLL: 'dddd, D MMMM YYYY [pukul] HH.mm' }, relativeTime: { future: 'wonten ing %s', past: '%s ingkang kepengker', s: 'sawetawis detik', m: 'setunggal menit', mm: '%d menit', h: 'setunggal jam', hh: '%d jam', d: 'sedinten', dd: '%d dinten', M: 'sewulan', MM: '%d wulan', y: 'setaun', yy: '%d taun' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ka.js ================================================ // Georgian [ka] import dayjs from 'dayjs' const locale = { name: 'ka', weekdays: 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'), weekdaysShort: 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'), weekdaysMin: 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'), months: 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'), monthsShort: 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'), weekStart: 1, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: '%s შემდეგ', past: '%s წინ', s: 'წამი', m: 'წუთი', mm: '%d წუთი', h: 'საათი', hh: '%d საათის', d: 'დღეს', dd: '%d დღის განმავლობაში', M: 'თვის', MM: '%d თვის', y: 'წელი', yy: '%d წლის' }, ordinal: n => n } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/kk.js ================================================ // Kazakh [kk] import dayjs from 'dayjs' const locale = { name: 'kk', weekdays: 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'), weekdaysShort: 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'), weekdaysMin: 'жк_дй_сй_ср_бй_жм_сн'.split('_'), months: 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'), monthsShort: 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'), weekStart: 1, relativeTime: { future: '%s ішінде', past: '%s бұрын', s: 'бірнеше секунд', m: 'бір минут', mm: '%d минут', h: 'бір сағат', hh: '%d сағат', d: 'бір күн', dd: '%d күн', M: 'бір ай', MM: '%d ай', y: 'бір жыл', yy: '%d жыл' }, ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/km.js ================================================ // Cambodian [km] import dayjs from 'dayjs' const locale = { name: 'km', weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'), months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'), weekStart: 1, weekdaysShort: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'), monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'), weekdaysMin: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: '%sទៀត', past: '%sមុន', s: 'ប៉ុន្មានវិនាទី', m: 'មួយនាទី', mm: '%d នាទី', h: 'មួយម៉ោង', hh: '%d ម៉ោង', d: 'មួយថ្ងៃ', dd: '%d ថ្ងៃ', M: 'មួយខែ', MM: '%d ខែ', y: 'មួយឆ្នាំ', yy: '%d ឆ្នាំ' }, meridiem: hour => (hour > 12 ? 'ល្ងាច' : 'ព្រឹក') } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/kn.js ================================================ // Kannada [kn] import dayjs from 'dayjs' const locale = { name: 'kn', weekdays: 'ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ'.split('_'), months: 'ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್'.split('_'), weekdaysShort: 'ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ'.split('_'), monthsShort: 'ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ'.split('_'), weekdaysMin: 'ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm', LTS: 'A h:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm', LLLL: 'dddd, D MMMM YYYY, A h:mm' }, relativeTime: { future: '%s ನಂತರ', past: '%s ಹಿಂದೆ', s: 'ಕೆಲವು ಕ್ಷಣಗಳು', m: 'ಒಂದು ನಿಮಿಷ', mm: '%d ನಿಮಿಷ', h: 'ಒಂದು ಗಂಟೆ', hh: '%d ಗಂಟೆ', d: 'ಒಂದು ದಿನ', dd: '%d ದಿನ', M: 'ಒಂದು ತಿಂಗಳು', MM: '%d ತಿಂಗಳು', y: 'ಒಂದು ವರ್ಷ', yy: '%d ವರ್ಷ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ko.js ================================================ // Korean [ko] import dayjs from 'dayjs' const locale = { name: 'ko', weekdays: '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'), weekdaysShort: '일_월_화_수_목_금_토'.split('_'), weekdaysMin: '일_월_화_수_목_금_토'.split('_'), months: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'), monthsShort: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'), ordinal: n => `${n}일`, formats: { LT: 'A h:mm', LTS: 'A h:mm:ss', L: 'YYYY.MM.DD.', LL: 'YYYY년 MMMM D일', LLL: 'YYYY년 MMMM D일 A h:mm', LLLL: 'YYYY년 MMMM D일 dddd A h:mm', l: 'YYYY.MM.DD.', ll: 'YYYY년 MMMM D일', lll: 'YYYY년 MMMM D일 A h:mm', llll: 'YYYY년 MMMM D일 dddd A h:mm' }, meridiem: hour => (hour < 12 ? '오전' : '오후'), relativeTime: { future: '%s 후', past: '%s 전', s: '몇 초', m: '1분', mm: '%d분', h: '한 시간', hh: '%d시간', d: '하루', dd: '%d일', M: '한 달', MM: '%d달', y: '일 년', yy: '%d년' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ku.js ================================================ // Kurdish [ku] import dayjs from 'dayjs' export const englishToArabicNumbersMap = { 1: '١', 2: '٢', 3: '٣', 4: '٤', 5: '٥', 6: '٦', 7: '٧', 8: '٨', 9: '٩', 0: '٠' } const arabicToEnglishNumbersMap = { '١': '1', '٢': '2', '٣': '3', '٤': '4', '٥': '5', '٦': '6', '٧': '7', '٨': '8', '٩': '9', '٠': '0' } const months = [ 'کانوونی دووەم', 'شوبات', 'ئادار', 'نیسان', 'ئایار', 'حوزەیران', 'تەممووز', 'ئاب', 'ئەیلوول', 'تشرینی یەکەم', 'تشرینی دووەم', 'کانوونی یەکەم' ] const locale = { name: 'ku', months, monthsShort: months, weekdays: 'یەکشەممە_دووشەممە_سێشەممە_چوارشەممە_پێنجشەممە_هەینی_شەممە'.split('_'), weekdaysShort: 'یەکشەم_دووشەم_سێشەم_چوارشەم_پێنجشەم_هەینی_شەممە'.split('_'), weekStart: 6, weekdaysMin: 'ی_د_س_چ_پ_هـ_ش'.split('_'), preparse(string) { return string .replace(/[١٢٣٤٥٦٧٨٩٠]/g, match => arabicToEnglishNumbersMap[match]) .replace(/،/g, ',') }, postformat(string) { return string .replace(/\d/g, match => englishToArabicNumbersMap[match]) .replace(/,/g, '،') }, ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, meridiem: hour => (hour < 12 ? 'پ.ن' : 'د.ن'), relativeTime: { future: 'لە %s', past: 'لەمەوپێش %s', s: 'چەند چرکەیەک', m: 'یەک خولەک', mm: '%d خولەک', h: 'یەک کاتژمێر', hh: '%d کاتژمێر', d: 'یەک ڕۆژ', dd: '%d ڕۆژ', M: 'یەک مانگ', MM: '%d مانگ', y: 'یەک ساڵ', yy: '%d ساڵ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ky.js ================================================ // Kyrgyz [ky] import dayjs from 'dayjs' const locale = { name: 'ky', weekdays: 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'), months: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'), weekStart: 1, weekdaysShort: 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'), monthsShort: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'), weekdaysMin: 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: '%s ичинде', past: '%s мурун', s: 'бирнече секунд', m: 'бир мүнөт', mm: '%d мүнөт', h: 'бир саат', hh: '%d саат', d: 'бир күн', dd: '%d күн', M: 'бир ай', MM: '%d ай', y: 'бир жыл', yy: '%d жыл' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/lb.js ================================================ // Luxembourgish [lb] import dayjs from 'dayjs' const locale = { name: 'lb', weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'), months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), weekStart: 1, weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'), monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'), weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'), ordinal: n => n, formats: { LT: 'H:mm [Auer]', LTS: 'H:mm:ss [Auer]', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm [Auer]', LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/lo.js ================================================ // Lao [lo] import dayjs from 'dayjs' const locale = { name: 'lo', weekdays: 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'), months: 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'), weekdaysShort: 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'), monthsShort: 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'), weekdaysMin: 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'ວັນdddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'ອີກ %s', past: '%sຜ່ານມາ', s: 'ບໍ່ເທົ່າໃດວິນາທີ', m: '1 ນາທີ', mm: '%d ນາທີ', h: '1 ຊົ່ວໂມງ', hh: '%d ຊົ່ວໂມງ', d: '1 ມື້', dd: '%d ມື້', M: '1 ເດືອນ', MM: '%d ເດືອນ', y: '1 ປີ', yy: '%d ປີ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/lt.js ================================================ // Lithuanian [lt] import dayjs from 'dayjs' const monthFormat = 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_') const monthStandalone = 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_') // eslint-disable-next-line no-useless-escape const MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/ const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const locale = { name: 'lt', weekdays: 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_'), weekdaysShort: 'sek_pir_ant_tre_ket_pen_šeš'.split('_'), weekdaysMin: 's_p_a_t_k_pn_š'.split('_'), months, monthsShort: 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'), ordinal: n => `${n}.`, weekStart: 1, relativeTime: { future: 'už %s', past: 'prieš %s', s: 'kelias sekundes', m: 'minutę', mm: '%d minutes', h: 'valandą', hh: '%d valandas', d: 'dieną', dd: '%d dienas', M: 'mėnesį', MM: '%d mėnesius', y: 'metus', yy: '%d metus' }, format: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'YYYY [m.] MMMM D [d.]', LLL: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', LLLL: 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]', l: 'YYYY-MM-DD', ll: 'YYYY [m.] MMMM D [d.]', lll: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', llll: 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'YYYY [m.] MMMM D [d.]', LLL: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', LLLL: 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]', l: 'YYYY-MM-DD', ll: 'YYYY [m.] MMMM D [d.]', lll: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', llll: 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/lv.js ================================================ // Latvian [lv] import dayjs from 'dayjs' const locale = { name: 'lv', weekdays: 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'), months: 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'), weekStart: 1, weekdaysShort: 'Sv_P_O_T_C_Pk_S'.split('_'), monthsShort: 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'), weekdaysMin: 'Sv_P_O_T_C_Pk_S'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY.', LL: 'YYYY. [gada] D. MMMM', LLL: 'YYYY. [gada] D. MMMM, HH:mm', LLLL: 'YYYY. [gada] D. MMMM, dddd, HH:mm' }, relativeTime: { future: 'pēc %s', past: 'pirms %s', s: 'dažām sekundēm', m: 'minūtes', mm: '%d minūtēm', h: 'stundas', hh: '%d stundām', d: 'dienas', dd: '%d dienām', M: 'mēneša', MM: '%d mēnešiem', y: 'gada', yy: '%d gadiem' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/me.js ================================================ // Montenegrin [me] import dayjs from 'dayjs' const locale = { name: 'me', weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'), months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'), weekStart: 1, weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'), monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'), weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), ordinal: n => n, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd, D. MMMM YYYY H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/mi.js ================================================ // Maori [mi] import dayjs from 'dayjs' const locale = { name: 'mi', weekdays: 'Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei'.split('_'), months: 'Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea'.split('_'), weekStart: 1, weekdaysShort: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'), monthsShort: 'Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki'.split('_'), weekdaysMin: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [i] HH:mm', LLLL: 'dddd, D MMMM YYYY [i] HH:mm' }, relativeTime: { future: 'i roto i %s', past: '%s i mua', s: 'te hēkona ruarua', m: 'he meneti', mm: '%d meneti', h: 'te haora', hh: '%d haora', d: 'he ra', dd: '%d ra', M: 'he marama', MM: '%d marama', y: 'he tau', yy: '%d tau' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/mk.js ================================================ // Macedonian [mk] import dayjs from 'dayjs' const locale = { name: 'mk', weekdays: 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'), months: 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'), weekStart: 1, weekdaysShort: 'нед_пон_вто_сре_чет_пет_саб'.split('_'), monthsShort: 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'), weekdaysMin: 'нe_пo_вт_ср_че_пе_сa'.split('_'), ordinal: n => n, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'D.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY H:mm', LLLL: 'dddd, D MMMM YYYY H:mm' }, relativeTime: { future: 'после %s', past: 'пред %s', s: 'неколку секунди', m: 'минута', mm: '%d минути', h: 'час', hh: '%d часа', d: 'ден', dd: '%d дена', M: 'месец', MM: '%d месеци', y: 'година', yy: '%d години' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ml.js ================================================ // Malayalam [ml] import dayjs from 'dayjs' const locale = { name: 'ml', weekdays: 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'), months: 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'), weekdaysShort: 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'), monthsShort: 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'), weekdaysMin: 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm -നു', LTS: 'A h:mm:ss -നു', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm -നു', LLLL: 'dddd, D MMMM YYYY, A h:mm -നു' }, relativeTime: { future: '%s കഴിഞ്ഞ്', past: '%s മുൻപ്', s: 'അൽപ നിമിഷങ്ങൾ', m: 'ഒരു മിനിറ്റ്', mm: '%d മിനിറ്റ്', h: 'ഒരു മണിക്കൂർ', hh: '%d മണിക്കൂർ', d: 'ഒരു ദിവസം', dd: '%d ദിവസം', M: 'ഒരു മാസം', MM: '%d മാസം', y: 'ഒരു വർഷം', yy: '%d വർഷം' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/mn.js ================================================ // Mongolian [mn] import dayjs from 'dayjs' const locale = { name: 'mn', weekdays: 'Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба'.split('_'), months: 'Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар'.split('_'), weekdaysShort: 'Ням_Дав_Мяг_Лха_Пүр_Баа_Бям'.split('_'), monthsShort: '1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар'.split('_'), weekdaysMin: 'Ня_Да_Мя_Лх_Пү_Ба_Бя'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'YYYY оны MMMMын D', LLL: 'YYYY оны MMMMын D HH:mm', LLLL: 'dddd, YYYY оны MMMMын D HH:mm' }, relativeTime: { future: '%s', past: '%s', s: 'саяхан', m: 'м', mm: '%dм', h: '1ц', hh: '%dц', d: '1ө', dd: '%dө', M: '1с', MM: '%dс', y: '1ж', yy: '%dж' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/mr.js ================================================ // Marathi [mr] import dayjs from 'dayjs' const locale = { name: 'mr', weekdays: 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), months: 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'), weekdaysShort: 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'), monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'), weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm वाजता', LTS: 'A h:mm:ss वाजता', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm वाजता', LLLL: 'dddd, D MMMM YYYY, A h:mm वाजता' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ms-my.js ================================================ // Malay [ms-my] import dayjs from 'dayjs' const locale = { name: 'ms-my', weekdays: 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'), months: 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'), weekStart: 1, weekdaysShort: 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'), monthsShort: 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'), weekdaysMin: 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'), ordinal: n => n, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [pukul] HH.mm', LLLL: 'dddd, D MMMM YYYY [pukul] HH.mm' }, relativeTime: { future: 'dalam %s', past: '%s yang lepas', s: 'beberapa saat', m: 'seminit', mm: '%d minit', h: 'sejam', hh: '%d jam', d: 'sehari', dd: '%d hari', M: 'sebulan', MM: '%d bulan', y: 'setahun', yy: '%d tahun' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ms.js ================================================ // Malay [ms] import dayjs from 'dayjs' const locale = { name: 'ms', weekdays: 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'), weekdaysShort: 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'), weekdaysMin: 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'), months: 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'), monthsShort: 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'), weekStart: 1, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH.mm', LLLL: 'dddd, D MMMM YYYY HH.mm' }, relativeTime: { future: 'dalam %s', past: '%s yang lepas', s: 'beberapa saat', m: 'seminit', mm: '%d minit', h: 'sejam', hh: '%d jam', d: 'sehari', dd: '%d hari', M: 'sebulan', MM: '%d bulan', y: 'setahun', yy: '%d tahun' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/mt.js ================================================ // Maltese (Malta) [mt] import dayjs from 'dayjs' const locale = { name: 'mt', weekdays: 'Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt'.split('_'), months: 'Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru'.split('_'), weekStart: 1, weekdaysShort: 'Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib'.split('_'), monthsShort: 'Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ'.split('_'), weekdaysMin: 'Ħa_Tn_Tl_Er_Ħa_Ġi_Si'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'f’ %s', past: '%s ilu', s: 'ftit sekondi', m: 'minuta', mm: '%d minuti', h: 'siegħa', hh: '%d siegħat', d: 'ġurnata', dd: '%d ġranet', M: 'xahar', MM: '%d xhur', y: 'sena', yy: '%d sni' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/my.js ================================================ // Burmese [my] import dayjs from 'dayjs' const locale = { name: 'my', weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'), months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'), weekStart: 1, weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'), monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'), weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'လာမည့် %s မှာ', past: 'လွန်ခဲ့သော %s က', s: 'စက္ကန်.အနည်းငယ်', m: 'တစ်မိနစ်', mm: '%d မိနစ်', h: 'တစ်နာရီ', hh: '%d နာရီ', d: 'တစ်ရက်', dd: '%d ရက်', M: 'တစ်လ', MM: '%d လ', y: 'တစ်နှစ်', yy: '%d နှစ်' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/nb.js ================================================ // Norwegian Bokmål [nb] import dayjs from 'dayjs' const locale = { name: 'nb', weekdays: 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'), weekdaysShort: 'sø._ma._ti._on._to._fr._lø.'.split('_'), weekdaysMin: 'sø_ma_ti_on_to_fr_lø'.split('_'), months: 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'), monthsShort: 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'), ordinal: n => `${n}.`, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY [kl.] HH:mm', LLLL: 'dddd D. MMMM YYYY [kl.] HH:mm' }, relativeTime: { future: 'om %s', past: '%s siden', s: 'noen sekunder', m: 'ett minutt', mm: '%d minutter', h: 'en time', hh: '%d timer', d: 'en dag', dd: '%d dager', M: 'en måned', MM: '%d måneder', y: 'ett år', yy: '%d år' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ne.js ================================================ // Nepalese [ne] import dayjs from 'dayjs' const locale = { name: 'ne', weekdays: 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'), weekdaysShort: 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'), weekdaysMin: 'आ._सो._मं._बु._बि._शु._श.'.split('_'), months: 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मे_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'), monthsShort: 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'), relativeTime: { future: '%s पछि', past: '%s अघि', s: 'सेकेन्ड', m: 'एक मिनेट', mm: '%d मिनेट', h: 'घन्टा', hh: '%d घन्टा', d: 'एक दिन', dd: '%d दिन', M: 'एक महिना', MM: '%d महिना', y: 'एक वर्ष', yy: '%d वर्ष' }, ordinal: n => `${n}`.replace(/\d/g, i => '०१२३४५६७८९'[i]), formats: { LT: 'Aको h:mm बजे', LTS: 'Aको h:mm:ss बजे', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, Aको h:mm बजे', LLLL: 'dddd, D MMMM YYYY, Aको h:mm बजे' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/nl-be.js ================================================ // Dutch (Belgium) [nl-be] import dayjs from 'dayjs' const locale = { name: 'nl-be', weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'), months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), monthsShort: 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'), weekStart: 1, weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'), weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'over %s', past: '%s geleden', s: 'een paar seconden', m: 'één minuut', mm: '%d minuten', h: 'één uur', hh: '%d uur', d: 'één dag', dd: '%d dagen', M: 'één maand', MM: '%d maanden', y: 'één jaar', yy: '%d jaar' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/nl.js ================================================ // Dutch [nl] import dayjs from 'dayjs' const locale = { name: 'nl', weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'), weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'), weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'), months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), monthsShort: 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'), ordinal: n => `[${n}${n === 1 || n === 8 || n >= 20 ? 'ste' : 'de'}]`, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD-MM-YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'over %s', past: '%s geleden', s: 'een paar seconden', m: 'een minuut', mm: '%d minuten', h: 'een uur', hh: '%d uur', d: 'een dag', dd: '%d dagen', M: 'een maand', MM: '%d maanden', y: 'een jaar', yy: '%d jaar' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/nn.js ================================================ // Nynorsk [nn] import dayjs from 'dayjs' const locale = { name: 'nn', weekdays: 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'), weekdaysShort: 'sun_mån_tys_ons_tor_fre_lau'.split('_'), weekdaysMin: 'su_må_ty_on_to_fr_la'.split('_'), months: 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'), monthsShort: 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'), ordinal: n => `${n}.`, weekStart: 1, relativeTime: { future: 'om %s', past: 'for %s sidan', s: 'nokre sekund', m: 'eitt minutt', mm: '%d minutt', h: 'ein time', hh: '%d timar', d: 'ein dag', dd: '%d dagar', M: 'ein månad', MM: '%d månadar', y: 'eitt år', yy: '%d år' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY [kl.] H:mm', LLLL: 'dddd D. MMMM YYYY [kl.] HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/oc-lnc.js ================================================ // Occitan, lengadocian dialecte [oc-lnc] import dayjs from 'dayjs' const locale = { name: 'oc-lnc', weekdays: 'dimenge_diluns_dimars_dimècres_dijòus_divendres_dissabte'.split('_'), weekdaysShort: 'Dg_Dl_Dm_Dc_Dj_Dv_Ds'.split('_'), weekdaysMin: 'dg_dl_dm_dc_dj_dv_ds'.split('_'), months: 'genièr_febrièr_març_abrial_mai_junh_julhet_agost_setembre_octòbre_novembre_decembre'.split('_'), monthsShort: 'gen_feb_març_abr_mai_junh_julh_ago_set_oct_nov_dec'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM [de] YYYY', LLL: 'D MMMM [de] YYYY [a] H:mm', LLLL: 'dddd D MMMM [de] YYYY [a] H:mm' }, relativeTime: { future: 'd\'aquí %s', past: 'fa %s', s: 'unas segondas', m: 'una minuta', mm: '%d minutas', h: 'una ora', hh: '%d oras', d: 'un jorn', dd: '%d jorns', M: 'un mes', MM: '%d meses', y: 'un an', yy: '%d ans' }, ordinal: n => `${n}º` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/pa-in.js ================================================ // Punjabi (India) [pa-in] import dayjs from 'dayjs' const locale = { name: 'pa-in', weekdays: 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'), months: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'), weekdaysShort: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'), monthsShort: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'), weekdaysMin: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm ਵਜੇ', LTS: 'A h:mm:ss ਵਜੇ', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm ਵਜੇ', LLLL: 'dddd, D MMMM YYYY, A h:mm ਵਜੇ' }, relativeTime: { future: '%s ਵਿੱਚ', past: '%s ਪਿਛਲੇ', s: 'ਕੁਝ ਸਕਿੰਟ', m: 'ਇਕ ਮਿੰਟ', mm: '%d ਮਿੰਟ', h: 'ਇੱਕ ਘੰਟਾ', hh: '%d ਘੰਟੇ', d: 'ਇੱਕ ਦਿਨ', dd: '%d ਦਿਨ', M: 'ਇੱਕ ਮਹੀਨਾ', MM: '%d ਮਹੀਨੇ', y: 'ਇੱਕ ਸਾਲ', yy: '%d ਸਾਲ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/pl.js ================================================ // Polish [pl] import dayjs from 'dayjs' function plural(n) { return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1) // eslint-disable-line } /* eslint-disable */ function translate(number, withoutSuffix, key) { const result = `${number} ` switch (key) { case 'm': return withoutSuffix ? 'minuta' : 'minutę' case 'mm': return result + (plural(number) ? 'minuty' : 'minut') case 'h': return withoutSuffix ? 'godzina' : 'godzinę' case 'hh': return result + (plural(number) ? 'godziny' : 'godzin') case 'MM': return result + (plural(number) ? 'miesiące' : 'miesięcy') case 'yy': return result + (plural(number) ? 'lata' : 'lat') } } /* eslint-enable */ const monthFormat = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_') const monthStandalone = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_') const MONTHS_IN_FORMAT = /D MMMM/ const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const locale = { name: 'pl', weekdays: 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'), weekdaysShort: 'ndz_pon_wt_śr_czw_pt_sob'.split('_'), weekdaysMin: 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'), months, monthsShort: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'), ordinal: n => `${n}.`, weekStart: 1, yearStart: 4, relativeTime: { future: 'za %s', past: '%s temu', s: 'kilka sekund', m: translate, mm: translate, h: translate, hh: translate, d: '1 dzień', dd: '%d dni', M: 'miesiąc', MM: translate, y: 'rok', yy: translate }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/pt-br.js ================================================ // Portuguese (Brazil) [pt-br] import dayjs from 'dayjs' const locale = { name: 'pt-br', weekdays: 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'), weekdaysShort: 'dom_seg_ter_qua_qui_sex_sáb'.split('_'), weekdaysMin: 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'), months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'), monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'), ordinal: n => `${n}º`, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY [às] HH:mm', LLLL: 'dddd, D [de] MMMM [de] YYYY [às] HH:mm' }, relativeTime: { future: 'em %s', past: 'há %s', s: 'poucos segundos', m: 'um minuto', mm: '%d minutos', h: 'uma hora', hh: '%d horas', d: 'um dia', dd: '%d dias', M: 'um mês', MM: '%d meses', y: 'um ano', yy: '%d anos' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/pt.js ================================================ // Portuguese [pt] import dayjs from 'dayjs' const locale = { name: 'pt', weekdays: 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'), weekdaysShort: 'dom_seg_ter_qua_qui_sex_sab'.split('_'), weekdaysMin: 'Do_2ª_3ª_4ª_5ª_6ª_Sa'.split('_'), months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'), monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'), ordinal: n => `${n}º`, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D [de] MMMM [de] YYYY', LLL: 'D [de] MMMM [de] YYYY [às] HH:mm', LLLL: 'dddd, D [de] MMMM [de] YYYY [às] HH:mm' }, relativeTime: { future: 'em %s', past: 'há %s', s: 'alguns segundos', m: 'um minuto', mm: '%d minutos', h: 'uma hora', hh: '%d horas', d: 'um dia', dd: '%d dias', M: 'um mês', MM: '%d meses', y: 'um ano', yy: '%d anos' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/rn.js ================================================ // Kirundi [rn] import dayjs from 'dayjs' const locale = { name: 'rn', weekdays: 'Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu'.split('_'), weekdaysShort: 'Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat'.split('_'), weekdaysMin: 'K7_K1_K2_K3_K4_K5_K6'.split('_'), months: 'Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama'.split('_'), monthsShort: 'Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig'.split('_'), weekStart: 1, ordinal: n => n, relativeTime: { future: 'mu %s', past: '%s', s: 'amasegonda', m: 'Umunota', mm: '%d iminota', h: 'isaha', hh: '%d amasaha', d: 'Umunsi', dd: '%d iminsi', M: 'ukwezi', MM: '%d amezi', y: 'umwaka', yy: '%d imyaka' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ro.js ================================================ // Romanian [ro] import dayjs from 'dayjs' const locale = { name: 'ro', weekdays: 'Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă'.split('_'), weekdaysShort: 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'), weekdaysMin: 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'), months: 'Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie'.split('_'), monthsShort: 'Ian._Febr._Mart._Apr._Mai_Iun._Iul._Aug._Sept._Oct._Nov._Dec.'.split('_'), weekStart: 1, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY H:mm', LLLL: 'dddd, D MMMM YYYY H:mm' }, relativeTime: { future: 'peste %s', past: 'acum %s', s: 'câteva secunde', m: 'un minut', mm: '%d minute', h: 'o oră', hh: '%d ore', d: 'o zi', dd: '%d zile', M: 'o lună', MM: '%d luni', y: 'un an', yy: '%d ani' }, ordinal: n => n } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ru.js ================================================ // Russian [ru] import dayjs from 'dayjs' const monthFormat = 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_') const monthStandalone = 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_') const monthShortFormat = 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_') const monthShortStandalone = 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_') const MONTHS_IN_FORMAT = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/ function plural(word, num) { const forms = word.split('_') return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]) // eslint-disable-line } function relativeTimeWithPlural(number, withoutSuffix, key) { const format = { mm: withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут', hh: 'час_часа_часов', dd: 'день_дня_дней', MM: 'месяц_месяца_месяцев', yy: 'год_года_лет' } if (key === 'm') { return withoutSuffix ? 'минута' : 'минуту' } return `${number} ${plural(format[key], +number)}` } const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const monthsShort = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthShortFormat[dayjsInstance.month()] } return monthShortStandalone[dayjsInstance.month()] } monthsShort.s = monthShortStandalone monthsShort.f = monthShortFormat const locale = { name: 'ru', weekdays: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'), weekdaysShort: 'вск_пнд_втр_срд_чтв_птн_сбт'.split('_'), weekdaysMin: 'вс_пн_вт_ср_чт_пт_сб'.split('_'), months, monthsShort, weekStart: 1, yearStart: 4, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY г.', LLL: 'D MMMM YYYY г., H:mm', LLLL: 'dddd, D MMMM YYYY г., H:mm' }, relativeTime: { future: 'через %s', past: '%s назад', s: 'несколько секунд', m: relativeTimeWithPlural, mm: relativeTimeWithPlural, h: 'час', hh: relativeTimeWithPlural, d: 'день', dd: relativeTimeWithPlural, M: 'месяц', MM: relativeTimeWithPlural, y: 'год', yy: relativeTimeWithPlural }, ordinal: n => n, meridiem: (hour) => { if (hour < 4) { return 'ночи' } else if (hour < 12) { return 'утра' } else if (hour < 17) { return 'дня' } return 'вечера' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/rw.js ================================================ // Kinyarwanda (Rwanda) [rw] import dayjs from 'dayjs' const locale = { name: 'rw', weekdays: 'Ku Cyumweru_Kuwa Mbere_Kuwa Kabiri_Kuwa Gatatu_Kuwa Kane_Kuwa Gatanu_Kuwa Gatandatu'.split('_'), months: 'Mutarama_Gashyantare_Werurwe_Mata_Gicurasi_Kamena_Nyakanga_Kanama_Nzeri_Ukwakira_Ugushyingo_Ukuboza'.split('_'), relativeTime: { future: 'mu %s', past: '%s', s: 'amasegonda', m: 'Umunota', mm: '%d iminota', h: 'isaha', hh: '%d amasaha', d: 'Umunsi', dd: '%d iminsi', M: 'ukwezi', MM: '%d amezi', y: 'umwaka', yy: '%d imyaka' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, ordinal: n => n } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sd.js ================================================ // Sindhi [sd] import dayjs from 'dayjs' const locale = { name: 'sd', weekdays: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), months: 'جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر'.split('_'), weekStart: 1, weekdaysShort: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), monthsShort: 'جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر'.split('_'), weekdaysMin: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd، D MMMM YYYY HH:mm' }, relativeTime: { future: '%s پوء', past: '%s اڳ', s: 'چند سيڪنڊ', m: 'هڪ منٽ', mm: '%d منٽ', h: 'هڪ ڪلاڪ', hh: '%d ڪلاڪ', d: 'هڪ ڏينهن', dd: '%d ڏينهن', M: 'هڪ مهينو', MM: '%d مهينا', y: 'هڪ سال', yy: '%d سال' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/se.js ================================================ // Northern Sami [se] import dayjs from 'dayjs' const locale = { name: 'se', weekdays: 'sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat'.split('_'), months: 'ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu'.split('_'), weekStart: 1, weekdaysShort: 'sotn_vuos_maŋ_gask_duor_bear_láv'.split('_'), monthsShort: 'ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov'.split('_'), weekdaysMin: 's_v_m_g_d_b_L'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'MMMM D. [b.] YYYY', LLL: 'MMMM D. [b.] YYYY [ti.] HH:mm', LLLL: 'dddd, MMMM D. [b.] YYYY [ti.] HH:mm' }, relativeTime: { future: '%s geažes', past: 'maŋit %s', s: 'moadde sekunddat', m: 'okta minuhta', mm: '%d minuhtat', h: 'okta diimmu', hh: '%d diimmut', d: 'okta beaivi', dd: '%d beaivvit', M: 'okta mánnu', MM: '%d mánut', y: 'okta jahki', yy: '%d jagit' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/si.js ================================================ // Sinhalese [si] import dayjs from 'dayjs' const locale = { name: 'si', weekdays: 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'), months: 'දුරුතු_නවම්_මැදින්_බක්_වෙසක්_පොසොන්_ඇසළ_නිකිණි_බිනර_වප්_ඉල්_උඳුවප්'.split('_'), weekdaysShort: 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'), monthsShort: 'දුරු_නව_මැදි_බක්_වෙස_පොසො_ඇස_නිකි_බින_වප්_ඉල්_උඳු'.split('_'), weekdaysMin: 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'), ordinal: n => n, formats: { LT: 'a h:mm', LTS: 'a h:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY MMMM D', LLL: 'YYYY MMMM D, a h:mm', LLLL: 'YYYY MMMM D [වැනි] dddd, a h:mm:ss' }, relativeTime: { future: '%sකින්', past: '%sකට පෙර', s: 'තත්පර කිහිපය', m: 'විනාඩිය', mm: 'විනාඩි %d', h: 'පැය', hh: 'පැය %d', d: 'දිනය', dd: 'දින %d', M: 'මාසය', MM: 'මාස %d', y: 'වසර', yy: 'වසර %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sk.js ================================================ // Slovak [sk] import dayjs from 'dayjs' function plural(n) { return (n > 1) && (n < 5) && (~~(n / 10) !== 1) // eslint-disable-line } /* eslint-disable */ function translate(number, withoutSuffix, key, isFuture) { const result = `${number} ` switch (key) { case 's': // a few seconds / in a few seconds / a few seconds ago return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami' case 'm': // a minute / in a minute / a minute ago return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou') case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'minúty' : 'minút') } return `${result}minútami` case 'h': // an hour / in an hour / an hour ago return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou') case 'hh': // 9 hours / in 9 hours / 9 hours ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'hodiny' : 'hodín') } return `${result}hodinami` case 'd': // a day / in a day / a day ago return (withoutSuffix || isFuture) ? 'deň' : 'dňom' case 'dd': // 9 days / in 9 days / 9 days ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'dni' : 'dní') } return `${result}dňami` case 'M': // a month / in a month / a month ago return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom' case 'MM': // 9 months / in 9 months / 9 months ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'mesiace' : 'mesiacov') } return `${result}mesiacmi` case 'y': // a year / in a year / a year ago return (withoutSuffix || isFuture) ? 'rok' : 'rokom' case 'yy': // 9 years / in 9 years / 9 years ago if (withoutSuffix || isFuture) { return result + (plural(number) ? 'roky' : 'rokov') } return `${result}rokmi` } } /* eslint-enable */ const locale = { name: 'sk', weekdays: 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'), weekdaysShort: 'ne_po_ut_st_št_pi_so'.split('_'), weekdaysMin: 'ne_po_ut_st_št_pi_so'.split('_'), months: 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'), monthsShort: 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_'), weekStart: 1, yearStart: 4, ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd D. MMMM YYYY H:mm', l: 'D. M. YYYY' }, relativeTime: { future: 'za %s', // Should be `o %s` (change when moment/moment#5408 is fixed) past: 'pred %s', s: translate, m: translate, mm: translate, h: translate, hh: translate, d: translate, dd: translate, M: translate, MM: translate, y: translate, yy: translate } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sl.js ================================================ // Slovenian [sl] import dayjs from 'dayjs' function dual(n) { return (n % 100) == 2 // eslint-disable-line } function threeFour(n) { return (n % 100) == 3 || (n % 100) == 4 // eslint-disable-line } /* eslint-disable */ function translate(number, withoutSuffix, key, isFuture) { const result = `${number} ` switch (key) { case 's': // a few seconds / in a few seconds / a few seconds ago return (withoutSuffix || isFuture) ? 'nekaj sekund' : 'nekaj sekundami' case 'm': // a minute / in a minute / a minute ago return withoutSuffix ? 'ena minuta' : 'eno minuto' case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago if (dual(number)) { return result + ((withoutSuffix || isFuture) ? 'minuti' : 'minutama') } if (threeFour(number)) { return result + ((withoutSuffix || isFuture) ? 'minute' : 'minutami') } return result + ((withoutSuffix || isFuture) ? 'minut' : 'minutami') case 'h': // an hour / in an hour / an hour ago return withoutSuffix ? 'ena ura' : (isFuture ? 'eno uro' : 'eno uro') case 'hh': // 9 hours / in 9 hours / 9 hours ago if (dual(number)) { return result + ((withoutSuffix || isFuture) ? 'uri' : 'urama') } if (threeFour(number)) { return result + ((withoutSuffix || isFuture) ? 'ure' : 'urami') } return result + ((withoutSuffix || isFuture) ? 'ur' : 'urami') case 'd': // a day / in a day / a day ago return (withoutSuffix || isFuture) ? 'en dan' : 'enim dnem' case 'dd': // 9 days / in 9 days / 9 days ago if (dual(number)) { return result + ((withoutSuffix || isFuture) ? 'dneva' : 'dnevoma') } return result + ((withoutSuffix || isFuture) ? 'dni' : 'dnevi') case 'M': // a month / in a month / a month ago return (withoutSuffix || isFuture) ? 'en mesec' : 'enim mesecem' case 'MM': // 9 months / in 9 months / 9 months ago if (dual(number)) { // 2 minutes / in 2 minutes return result + ((withoutSuffix || isFuture) ? 'meseca' : 'mesecema') } if (threeFour(number)) { return result + ((withoutSuffix || isFuture) ? 'mesece' : 'meseci') } return result + ((withoutSuffix || isFuture) ? 'mesecev' : 'meseci') case 'y': // a year / in a year / a year ago return (withoutSuffix || isFuture) ? 'eno leto' : 'enim letom' case 'yy': // 9 years / in 9 years / 9 years ago if (dual(number)) { // 2 minutes / in 2 minutes return result + ((withoutSuffix || isFuture) ? 'leti' : 'letoma') } if (threeFour(number)) { return result + ((withoutSuffix || isFuture) ? 'leta' : 'leti') } return result + ((withoutSuffix || isFuture) ? 'let' : 'leti') } } /* eslint-enable */ const locale = { name: 'sl', weekdays: 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'), months: 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'), weekStart: 1, weekdaysShort: 'ned._pon._tor._sre._čet._pet._sob.'.split('_'), monthsShort: 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'), weekdaysMin: 'ne_po_to_sr_če_pe_so'.split('_'), ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', LLLL: 'dddd, D. MMMM YYYY H:mm', l: 'D. M. YYYY' }, relativeTime: { future: 'čez %s', past: 'pred %s', s: translate, m: translate, mm: translate, h: translate, hh: translate, d: translate, dd: translate, M: translate, MM: translate, y: translate, yy: translate } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sq.js ================================================ // Albanian [sq] import dayjs from 'dayjs' const locale = { name: 'sq', weekdays: 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'), months: 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'), weekStart: 1, weekdaysShort: 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'), monthsShort: 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'), weekdaysMin: 'D_H_Ma_Më_E_P_Sh'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'në %s', past: '%s më parë', s: 'disa sekonda', m: 'një minutë', mm: '%d minuta', h: 'një orë', hh: '%d orë', d: 'një ditë', dd: '%d ditë', M: 'një muaj', MM: '%d muaj', y: 'një vit', yy: '%d vite' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sr-cyrl.js ================================================ // Serbian Cyrillic [sr-cyrl] import dayjs from 'dayjs' const translator = { words: { m: ['један минут', 'једног минута'], mm: ['%d минут', '%d минута', '%d минута'], h: ['један сат', 'једног сата'], hh: ['%d сат', '%d сата', '%d сати'], d: ['један дан', 'једног дана'], dd: ['%d дан', '%d дана', '%d дана'], M: ['један месец', 'једног месеца'], MM: ['%d месец', '%d месеца', '%d месеци'], y: ['једну годину', 'једне године'], yy: ['%d годину', '%d године', '%d година'] }, correctGrammarCase(number, wordKey) { if (number % 10 >= 1 && number % 10 <= 4 && (number % 100 < 10 || number % 100 >= 20)) { return number % 10 === 1 ? wordKey[0] : wordKey[1] } return wordKey[2] }, relativeTimeFormatter(number, withoutSuffix, key, isFuture) { const wordKey = translator.words[key] if (key.length === 1) { // Nominativ if (key === 'y' && withoutSuffix) return 'једна година' return isFuture || withoutSuffix ? wordKey[0] : wordKey[1] } const word = translator.correctGrammarCase(number, wordKey) // Nominativ if (key === 'yy' && withoutSuffix && word === '%d годину') return `${number} година` return word.replace('%d', number) } } const locale = { name: 'sr-cyrl', weekdays: 'Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота'.split('_'), weekdaysShort: 'Нед._Пон._Уто._Сре._Чет._Пет._Суб.'.split('_'), weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'), months: 'Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар'.split('_'), monthsShort: 'Јан._Феб._Мар._Апр._Мај_Јун_Јул_Авг._Сеп._Окт._Нов._Дец.'.split('_'), weekStart: 1, relativeTime: { future: 'за %s', past: 'пре %s', s: 'неколико секунди', m: translator.relativeTimeFormatter, mm: translator.relativeTimeFormatter, h: translator.relativeTimeFormatter, hh: translator.relativeTimeFormatter, d: translator.relativeTimeFormatter, dd: translator.relativeTimeFormatter, M: translator.relativeTimeFormatter, MM: translator.relativeTimeFormatter, y: translator.relativeTimeFormatter, yy: translator.relativeTimeFormatter }, ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'D. M. YYYY.', LL: 'D. MMMM YYYY.', LLL: 'D. MMMM YYYY. H:mm', LLLL: 'dddd, D. MMMM YYYY. H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sr.js ================================================ // Serbian [sr] import dayjs from 'dayjs' const translator = { words: { m: ['jedan minut', 'jednog minuta'], mm: ['%d minut', '%d minuta', '%d minuta'], h: ['jedan sat', 'jednog sata'], hh: ['%d sat', '%d sata', '%d sati'], d: ['jedan dan', 'jednog dana'], dd: ['%d dan', '%d dana', '%d dana'], M: ['jedan mesec', 'jednog meseca'], MM: ['%d mesec', '%d meseca', '%d meseci'], y: ['jednu godinu', 'jedne godine'], yy: ['%d godinu', '%d godine', '%d godina'] }, correctGrammarCase(number, wordKey) { if (number % 10 >= 1 && number % 10 <= 4 && (number % 100 < 10 || number % 100 >= 20)) { return number % 10 === 1 ? wordKey[0] : wordKey[1] } return wordKey[2] }, relativeTimeFormatter(number, withoutSuffix, key, isFuture) { const wordKey = translator.words[key] if (key.length === 1) { // Nominativ if (key === 'y' && withoutSuffix) return 'jedna godina' return isFuture || withoutSuffix ? wordKey[0] : wordKey[1] } const word = translator.correctGrammarCase(number, wordKey) // Nominativ if (key === 'yy' && withoutSuffix && word === '%d godinu') return `${number} godina` return word.replace('%d', number) } } const locale = { name: 'sr', weekdays: 'Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota'.split('_'), weekdaysShort: 'Ned._Pon._Uto._Sre._Čet._Pet._Sub.'.split('_'), weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), months: 'Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar'.split('_'), monthsShort: 'Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.'.split('_'), weekStart: 1, relativeTime: { future: 'za %s', past: 'pre %s', s: 'nekoliko sekundi', m: translator.relativeTimeFormatter, mm: translator.relativeTimeFormatter, h: translator.relativeTimeFormatter, hh: translator.relativeTimeFormatter, d: translator.relativeTimeFormatter, dd: translator.relativeTimeFormatter, M: translator.relativeTimeFormatter, MM: translator.relativeTimeFormatter, y: translator.relativeTimeFormatter, yy: translator.relativeTimeFormatter }, ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'D. M. YYYY.', LL: 'D. MMMM YYYY.', LLL: 'D. MMMM YYYY. H:mm', LLLL: 'dddd, D. MMMM YYYY. H:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ss.js ================================================ // siSwati [ss] import dayjs from 'dayjs' const locale = { name: 'ss', weekdays: 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'), months: "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'), weekStart: 1, weekdaysShort: 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'), monthsShort: 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'), weekdaysMin: 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'), ordinal: n => n, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: 'nga %s', past: 'wenteka nga %s', s: 'emizuzwana lomcane', m: 'umzuzu', mm: '%d emizuzu', h: 'lihora', hh: '%d emahora', d: 'lilanga', dd: '%d emalanga', M: 'inyanga', MM: '%d tinyanga', y: 'umnyaka', yy: '%d iminyaka' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sv-fi.js ================================================ // Finland Swedish [sv-fi] import dayjs from 'dayjs' const locale = { name: 'sv-fi', weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'), weekdaysShort: 'sön_mån_tis_ons_tor_fre_lör'.split('_'), weekdaysMin: 'sö_må_ti_on_to_fr_lö'.split('_'), months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'), monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'), weekStart: 1, yearStart: 4, ordinal: (n) => { const b = n % 10 const o = (b === 1) || (b === 2) ? 'a' : 'e' return `[${n}${o}]` }, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY, [kl.] HH.mm', LLLL: 'dddd, D. MMMM YYYY, [kl.] HH.mm', l: 'D.M.YYYY', ll: 'D. MMM YYYY', lll: 'D. MMM YYYY, [kl.] HH.mm', llll: 'ddd, D. MMM YYYY, [kl.] HH.mm' }, relativeTime: { future: 'om %s', past: 'för %s sedan', s: 'några sekunder', m: 'en minut', mm: '%d minuter', h: 'en timme', hh: '%d timmar', d: 'en dag', dd: '%d dagar', M: 'en månad', MM: '%d månader', y: 'ett år', yy: '%d år' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sv.js ================================================ // Swedish [sv] import dayjs from 'dayjs' const locale = { name: 'sv', weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'), weekdaysShort: 'sön_mån_tis_ons_tor_fre_lör'.split('_'), weekdaysMin: 'sö_må_ti_on_to_fr_lö'.split('_'), months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'), monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'), weekStart: 1, yearStart: 4, ordinal: (n) => { const b = n % 10 const o = (b === 1) || (b === 2) ? 'a' : 'e' return `[${n}${o}]` }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [kl.] HH:mm', LLLL: 'dddd D MMMM YYYY [kl.] HH:mm', lll: 'D MMM YYYY HH:mm', llll: 'ddd D MMM YYYY HH:mm' }, relativeTime: { future: 'om %s', past: 'för %s sedan', s: 'några sekunder', m: 'en minut', mm: '%d minuter', h: 'en timme', hh: '%d timmar', d: 'en dag', dd: '%d dagar', M: 'en månad', MM: '%d månader', y: 'ett år', yy: '%d år' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/sw.js ================================================ // Swahili [sw] import dayjs from 'dayjs' const locale = { name: 'sw', weekdays: 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'), weekdaysShort: 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'), weekdaysMin: 'J2_J3_J4_J5_Al_Ij_J1'.split('_'), months: 'Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba'.split('_'), monthsShort: 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des'.split('_'), weekStart: 1, ordinal: n => n, relativeTime: { future: '%s baadaye', past: 'tokea %s', s: 'hivi punde', m: 'dakika moja', mm: 'dakika %d', h: 'saa limoja', hh: 'masaa %d', d: 'siku moja', dd: 'masiku %d', M: 'mwezi mmoja', MM: 'miezi %d', y: 'mwaka mmoja', yy: 'miaka %d' }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ta.js ================================================ // Tamil [ta] import dayjs from 'dayjs' const locale = { name: 'ta', weekdays: 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'), months: 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'), weekdaysShort: 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'), monthsShort: 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'), weekdaysMin: 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, HH:mm', LLLL: 'dddd, D MMMM YYYY, HH:mm' }, relativeTime: { future: '%s இல்', past: '%s முன்', s: 'ஒரு சில விநாடிகள்', m: 'ஒரு நிமிடம்', mm: '%d நிமிடங்கள்', h: 'ஒரு மணி நேரம்', hh: '%d மணி நேரம்', d: 'ஒரு நாள்', dd: '%d நாட்கள்', M: 'ஒரு மாதம்', MM: '%d மாதங்கள்', y: 'ஒரு வருடம்', yy: '%d ஆண்டுகள்' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/te.js ================================================ // Telugu [te] import dayjs from 'dayjs' const locale = { name: 'te', weekdays: 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'), months: 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'), weekdaysShort: 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'), monthsShort: 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'), weekdaysMin: 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'), ordinal: n => n, formats: { LT: 'A h:mm', LTS: 'A h:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY, A h:mm', LLLL: 'dddd, D MMMM YYYY, A h:mm' }, relativeTime: { future: '%s లో', past: '%s క్రితం', s: 'కొన్ని క్షణాలు', m: 'ఒక నిమిషం', mm: '%d నిమిషాలు', h: 'ఒక గంట', hh: '%d గంటలు', d: 'ఒక రోజు', dd: '%d రోజులు', M: 'ఒక నెల', MM: '%d నెలలు', y: 'ఒక సంవత్సరం', yy: '%d సంవత్సరాలు' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tet.js ================================================ // Tetun Dili (East Timor) [tet] import dayjs from 'dayjs' const locale = { name: 'tet', weekdays: 'Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu'.split('_'), months: 'Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru'.split('_'), weekStart: 1, weekdaysShort: 'Dom_Seg_Ters_Kua_Kint_Sest_Sab'.split('_'), monthsShort: 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'), weekdaysMin: 'Do_Seg_Te_Ku_Ki_Ses_Sa'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'iha %s', past: '%s liuba', s: 'minutu balun', m: 'minutu ida', mm: 'minutu %d', h: 'oras ida', hh: 'oras %d', d: 'loron ida', dd: 'loron %d', M: 'fulan ida', MM: 'fulan %d', y: 'tinan ida', yy: 'tinan %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tg.js ================================================ // Tajik [tg] import dayjs from 'dayjs' const locale = { name: 'tg', weekdays: 'якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе'.split('_'), months: 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'), weekStart: 1, weekdaysShort: 'яшб_дшб_сшб_чшб_пшб_ҷум_шнб'.split('_'), monthsShort: 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'), weekdaysMin: 'яш_дш_сш_чш_пш_ҷм_шб'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'баъди %s', past: '%s пеш', s: 'якчанд сония', m: 'як дақиқа', mm: '%d дақиқа', h: 'як соат', hh: '%d соат', d: 'як рӯз', dd: '%d рӯз', M: 'як моҳ', MM: '%d моҳ', y: 'як сол', yy: '%d сол' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/th.js ================================================ // Thai [th] import dayjs from 'dayjs' const locale = { name: 'th', weekdays: 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'), weekdaysShort: 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), weekdaysMin: 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'), months: 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'), monthsShort: 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'), formats: { LT: 'H:mm', LTS: 'H:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY เวลา H:mm', LLLL: 'วันddddที่ D MMMM YYYY เวลา H:mm' }, relativeTime: { future: 'อีก %s', past: '%sที่แล้ว', s: 'ไม่กี่วินาที', m: '1 นาที', mm: '%d นาที', h: '1 ชั่วโมง', hh: '%d ชั่วโมง', d: '1 วัน', dd: '%d วัน', M: '1 เดือน', MM: '%d เดือน', y: '1 ปี', yy: '%d ปี' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tk.js ================================================ // Turkmen [tk] import dayjs from 'dayjs' const locale = { name: 'tk', weekdays: 'Ýekşenbe_Duşenbe_Sişenbe_Çarşenbe_Penşenbe_Anna_Şenbe'.split('_'), weekdaysShort: 'Ýek_Duş_Siş_Çar_Pen_Ann_Şen'.split('_'), weekdaysMin: 'Ýk_Dş_Sş_Çr_Pn_An_Şn'.split('_'), months: 'Ýanwar_Fewral_Mart_Aprel_Maý_Iýun_Iýul_Awgust_Sentýabr_Oktýabr_Noýabr_Dekabr'.split('_'), monthsShort: 'Ýan_Few_Mar_Apr_Maý_Iýn_Iýl_Awg_Sen_Okt_Noý_Dek'.split('_'), weekStart: 1, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: '%s soň', past: '%s öň', s: 'birnäçe sekunt', m: 'bir minut', mm: '%d minut', h: 'bir sagat', hh: '%d sagat', d: 'bir gün', dd: '%d gün', M: 'bir aý', MM: '%d aý', y: 'bir ýyl', yy: '%d ýyl' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tl-ph.js ================================================ // Tagalog (Philippines) [tl-ph] import dayjs from 'dayjs' const locale = { name: 'tl-ph', weekdays: 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'), months: 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'), weekStart: 1, weekdaysShort: 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'), monthsShort: 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'), weekdaysMin: 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'MM/D/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY HH:mm', LLLL: 'dddd, MMMM DD, YYYY HH:mm' }, relativeTime: { future: 'sa loob ng %s', past: '%s ang nakalipas', s: 'ilang segundo', m: 'isang minuto', mm: '%d minuto', h: 'isang oras', hh: '%d oras', d: 'isang araw', dd: '%d araw', M: 'isang buwan', MM: '%d buwan', y: 'isang taon', yy: '%d taon' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tlh.js ================================================ // Klingon [tlh] import dayjs from 'dayjs' const locale = { name: 'tlh', weekdays: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), months: 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'), weekStart: 1, weekdaysShort: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), monthsShort: 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'), weekdaysMin: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tr.js ================================================ // Turkish [tr] import dayjs from 'dayjs' const locale = { name: 'tr', weekdays: 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'), weekdaysShort: 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'), weekdaysMin: 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'), months: 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'), monthsShort: 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'), weekStart: 1, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: '%s sonra', past: '%s önce', s: 'birkaç saniye', m: 'bir dakika', mm: '%d dakika', h: 'bir saat', hh: '%d saat', d: 'bir gün', dd: '%d gün', M: 'bir ay', MM: '%d ay', y: 'bir yıl', yy: '%d yıl' }, ordinal: n => `${n}.` } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tzl.js ================================================ // Talossan [tzl] import dayjs from 'dayjs' const locale = { name: 'tzl', weekdays: 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'), months: 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'), weekStart: 1, weekdaysShort: 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'), monthsShort: 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'), weekdaysMin: 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'), ordinal: n => n, formats: { LT: 'HH.mm', LTS: 'HH.mm.ss', L: 'DD.MM.YYYY', LL: 'D. MMMM [dallas] YYYY', LLL: 'D. MMMM [dallas] YYYY HH.mm', LLLL: 'dddd, [li] D. MMMM [dallas] YYYY HH.mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tzm-latn.js ================================================ // Central Atlas Tamazight Latin [tzm-latn] import dayjs from 'dayjs' const locale = { name: 'tzm-latn', weekdays: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), months: 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'), weekStart: 6, weekdaysShort: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), monthsShort: 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'), weekdaysMin: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'dadkh s yan %s', past: 'yan %s', s: 'imik', m: 'minuḍ', mm: '%d minuḍ', h: 'saɛa', hh: '%d tassaɛin', d: 'ass', dd: '%d ossan', M: 'ayowr', MM: '%d iyyirn', y: 'asgas', yy: '%d isgasn' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/tzm.js ================================================ // Central Atlas Tamazight [tzm] import dayjs from 'dayjs' const locale = { name: 'tzm', weekdays: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), months: 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), weekStart: 6, weekdaysShort: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), monthsShort: 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), weekdaysMin: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, relativeTime: { future: 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s', past: 'ⵢⴰⵏ %s', s: 'ⵉⵎⵉⴽ', m: 'ⵎⵉⵏⵓⴺ', mm: '%d ⵎⵉⵏⵓⴺ', h: 'ⵙⴰⵄⴰ', hh: '%d ⵜⴰⵙⵙⴰⵄⵉⵏ', d: 'ⴰⵙⵙ', dd: '%d oⵙⵙⴰⵏ', M: 'ⴰⵢoⵓⵔ', MM: '%d ⵉⵢⵢⵉⵔⵏ', y: 'ⴰⵙⴳⴰⵙ', yy: '%d ⵉⵙⴳⴰⵙⵏ' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ug-cn.js ================================================ // Uyghur (China) [ug-cn] import dayjs from 'dayjs' const locale = { name: 'ug-cn', weekdays: 'يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە'.split('_'), months: 'يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر'.split('_'), weekStart: 1, weekdaysShort: 'يە_دۈ_سە_چا_پە_جۈ_شە'.split('_'), monthsShort: 'يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر'.split('_'), weekdaysMin: 'يە_دۈ_سە_چا_پە_جۈ_شە'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY-MM-DD', LL: 'YYYY-يىلىM-ئاينىڭD-كۈنى', LLL: 'YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm', LLLL: 'dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm' }, relativeTime: { future: '%s كېيىن', past: '%s بۇرۇن', s: 'نەچچە سېكونت', m: 'بىر مىنۇت', mm: '%d مىنۇت', h: 'بىر سائەت', hh: '%d سائەت', d: 'بىر كۈن', dd: '%d كۈن', M: 'بىر ئاي', MM: '%d ئاي', y: 'بىر يىل', yy: '%d يىل' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/uk.js ================================================ // Ukrainian [uk] import dayjs from 'dayjs' const monthFormat = 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_') const monthStandalone = 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_') const MONTHS_IN_FORMAT = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/ function plural(word, num) { const forms = word.split('_') return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]) // eslint-disable-line } function relativeTimeWithPlural(number, withoutSuffix, key) { const format = { ss: withoutSuffix ? 'секунда_секунди_секунд' : 'секунду_секунди_секунд', mm: withoutSuffix ? 'хвилина_хвилини_хвилин' : 'хвилину_хвилини_хвилин', hh: withoutSuffix ? 'година_години_годин' : 'годину_години_годин', dd: 'день_дні_днів', MM: 'місяць_місяці_місяців', yy: 'рік_роки_років' } if (key === 'm') { return withoutSuffix ? 'хвилина' : 'хвилину' } else if (key === 'h') { return withoutSuffix ? 'година' : 'годину' } return `${number} ${plural(format[key], +number)}` } const months = (dayjsInstance, format) => { if (MONTHS_IN_FORMAT.test(format)) { return monthFormat[dayjsInstance.month()] } return monthStandalone[dayjsInstance.month()] } months.s = monthStandalone months.f = monthFormat const locale = { name: 'uk', weekdays: 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'), weekdaysShort: 'ндл_пнд_втр_срд_чтв_птн_сбт'.split('_'), weekdaysMin: 'нд_пн_вт_ср_чт_пт_сб'.split('_'), months, monthsShort: 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'), weekStart: 1, relativeTime: { future: 'за %s', past: '%s тому', s: 'декілька секунд', m: relativeTimeWithPlural, mm: relativeTimeWithPlural, h: relativeTimeWithPlural, hh: relativeTimeWithPlural, d: 'день', dd: relativeTimeWithPlural, M: 'місяць', MM: relativeTimeWithPlural, y: 'рік', yy: relativeTimeWithPlural }, ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD.MM.YYYY', LL: 'D MMMM YYYY р.', LLL: 'D MMMM YYYY р., HH:mm', LLLL: 'dddd, D MMMM YYYY р., HH:mm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/ur.js ================================================ // Urdu [ur] import dayjs from 'dayjs' const locale = { name: 'ur', weekdays: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), months: 'جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر'.split('_'), weekStart: 1, weekdaysShort: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), monthsShort: 'جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر'.split('_'), weekdaysMin: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd، D MMMM YYYY HH:mm' }, relativeTime: { future: '%s بعد', past: '%s قبل', s: 'چند سیکنڈ', m: 'ایک منٹ', mm: '%d منٹ', h: 'ایک گھنٹہ', hh: '%d گھنٹے', d: 'ایک دن', dd: '%d دن', M: 'ایک ماہ', MM: '%d ماہ', y: 'ایک سال', yy: '%d سال' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/uz-latn.js ================================================ // Uzbek Latin [uz-latn] import dayjs from 'dayjs' const locale = { name: 'uz-latn', weekdays: 'Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba'.split('_'), months: 'Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr'.split('_'), weekStart: 1, weekdaysShort: 'Yak_Dush_Sesh_Chor_Pay_Jum_Shan'.split('_'), monthsShort: 'Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek'.split('_'), weekdaysMin: 'Ya_Du_Se_Cho_Pa_Ju_Sha'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'D MMMM YYYY, dddd HH:mm' }, relativeTime: { future: 'Yaqin %s ichida', past: '%s oldin', s: 'soniya', m: 'bir daqiqa', mm: '%d daqiqa', h: 'bir soat', hh: '%d soat', d: 'bir kun', dd: '%d kun', M: 'bir oy', MM: '%d oy', y: 'bir yil', yy: '%d yil' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/uz.js ================================================ // Uzbek [uz] import dayjs from 'dayjs' const locale = { name: 'uz', weekdays: 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'), months: 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'), weekStart: 1, weekdaysShort: 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'), monthsShort: 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'), weekdaysMin: 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'D MMMM YYYY, dddd HH:mm' }, relativeTime: { future: 'Якин %s ичида', past: '%s олдин', s: 'фурсат', m: 'бир дакика', mm: '%d дакика', h: 'бир соат', hh: '%d соат', d: 'бир кун', dd: '%d кун', M: 'бир ой', MM: '%d ой', y: 'бир йил', yy: '%d йил' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/vi.js ================================================ // Vietnamese [vi] import dayjs from 'dayjs' const locale = { name: 'vi', weekdays: 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'), months: 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'), weekStart: 1, weekdaysShort: 'CN_T2_T3_T4_T5_T6_T7'.split('_'), monthsShort: 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'), weekdaysMin: 'CN_T2_T3_T4_T5_T6_T7'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM [năm] YYYY', LLL: 'D MMMM [năm] YYYY HH:mm', LLLL: 'dddd, D MMMM [năm] YYYY HH:mm', l: 'DD/M/YYYY', ll: 'D MMM YYYY', lll: 'D MMM YYYY HH:mm', llll: 'ddd, D MMM YYYY HH:mm' }, relativeTime: { future: '%s tới', past: '%s trước', s: 'vài giây', m: 'một phút', mm: '%d phút', h: 'một giờ', hh: '%d giờ', d: 'một ngày', dd: '%d ngày', M: 'một tháng', MM: '%d tháng', y: 'một năm', yy: '%d năm' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/x-pseudo.js ================================================ // Pseudo [x-pseudo] import dayjs from 'dayjs' const locale = { name: 'x-pseudo', weekdays: 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'), months: 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'), weekStart: 1, weekdaysShort: 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'), monthsShort: 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'), weekdaysMin: 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'), ordinal: n => n, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'í~ñ %s', past: '%s á~gó', s: 'á ~féw ~sécó~ñds', m: 'á ~míñ~úté', mm: '%d m~íñú~tés', h: 'á~ñ hó~úr', hh: '%d h~óúrs', d: 'á ~dáý', dd: '%d d~áýs', M: 'á ~móñ~th', MM: '%d m~óñt~hs', y: 'á ~ýéár', yy: '%d ý~éárs' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/yo.js ================================================ // Yoruba Nigeria [yo] import dayjs from 'dayjs' const locale = { name: 'yo', weekdays: 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), months: 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), weekStart: 1, weekdaysShort: 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), monthsShort: 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), weekdaysMin: 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), ordinal: n => n, formats: { LT: 'h:mm A', LTS: 'h:mm:ss A', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY h:mm A', LLLL: 'dddd, D MMMM YYYY h:mm A' }, relativeTime: { future: 'ní %s', past: '%s kọjá', s: 'ìsẹjú aayá die', m: 'ìsẹjú kan', mm: 'ìsẹjú %d', h: 'wákati kan', hh: 'wákati %d', d: 'ọjọ́ kan', dd: 'ọjọ́ %d', M: 'osù kan', MM: 'osù %d', y: 'ọdún kan', yy: 'ọdún %d' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/zh-cn.js ================================================ // Chinese (China) [zh-cn] import dayjs from 'dayjs' const locale = { name: 'zh-cn', weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), weekdaysMin: '日_一_二_三_四_五_六'.split('_'), months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), ordinal: (number, period) => { switch (period) { case 'W': return `${number}周` default: return `${number}日` } }, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日Ah点mm分', LLLL: 'YYYY年M月D日ddddAh点mm分', l: 'YYYY/M/D', ll: 'YYYY年M月D日', lll: 'YYYY年M月D日 HH:mm', llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s内', past: '%s前', s: '几秒', m: '1 分钟', mm: '%d 分钟', h: '1 小时', hh: '%d 小时', d: '1 天', dd: '%d 天', M: '1 个月', MM: '%d 个月', y: '1 年', yy: '%d 年' }, meridiem: (hour, minute) => { const hm = (hour * 100) + minute if (hm < 600) { return '凌晨' } else if (hm < 900) { return '早上' } else if (hm < 1100) { return '上午' } else if (hm < 1300) { return '中午' } else if (hm < 1800) { return '下午' } return '晚上' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/zh-hk.js ================================================ // Chinese (Hong Kong) [zh-hk] import dayjs from 'dayjs' const locale = { name: 'zh-hk', months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), weekdaysShort: '週日_週一_週二_週三_週四_週五_週六'.split('_'), weekdaysMin: '日_一_二_三_四_五_六'.split('_'), ordinal: (number, period) => { switch (period) { case 'W': return `${number}週` default: return `${number}日` } }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', LLLL: 'YYYY年M月D日dddd HH:mm', l: 'YYYY/M/D', ll: 'YYYY年M月D日', lll: 'YYYY年M月D日 HH:mm', llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s內', past: '%s前', s: '幾秒', m: '一分鐘', mm: '%d 分鐘', h: '一小時', hh: '%d 小時', d: '一天', dd: '%d 天', M: '一個月', MM: '%d 個月', y: '一年', yy: '%d 年' }, meridiem: (hour, minute) => { const hm = (hour * 100) + minute if (hm < 600) { return '凌晨' } else if (hm < 900) { return '早上' } else if (hm < 1100) { return '上午' } else if (hm < 1300) { return '中午' } else if (hm < 1800) { return '下午' } return '晚上' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/zh-tw.js ================================================ // Chinese (Taiwan) [zh-tw] import dayjs from 'dayjs' const locale = { name: 'zh-tw', weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), weekdaysShort: '週日_週一_週二_週三_週四_週五_週六'.split('_'), weekdaysMin: '日_一_二_三_四_五_六'.split('_'), months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), ordinal: (number, period) => { switch (period) { case 'W': return `${number}週` default: return `${number}日` } }, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', LLLL: 'YYYY年M月D日dddd HH:mm', l: 'YYYY/M/D', ll: 'YYYY年M月D日', lll: 'YYYY年M月D日 HH:mm', llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s內', past: '%s前', s: '幾秒', m: '1 分鐘', mm: '%d 分鐘', h: '1 小時', hh: '%d 小時', d: '1 天', dd: '%d 天', M: '1 個月', MM: '%d 個月', y: '1 年', yy: '%d 年' }, meridiem: (hour, minute) => { const hm = (hour * 100) + minute if (hm < 600) { return '凌晨' } else if (hm < 900) { return '早上' } else if (hm < 1100) { return '上午' } else if (hm < 1300) { return '中午' } else if (hm < 1800) { return '下午' } return '晚上' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/locale/zh.js ================================================ // Chinese [zh] import dayjs from 'dayjs' const locale = { name: 'zh', weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), weekdaysMin: '日_一_二_三_四_五_六'.split('_'), months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), ordinal: (number, period) => { switch (period) { case 'W': return `${number}周` default: return `${number}日` } }, weekStart: 1, yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日Ah点mm分', LLLL: 'YYYY年M月D日ddddAh点mm分', l: 'YYYY/M/D', ll: 'YYYY年M月D日', lll: 'YYYY年M月D日 HH:mm', llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s后', past: '%s前', s: '几秒', m: '1 分钟', mm: '%d 分钟', h: '1 小时', hh: '%d 小时', d: '1 天', dd: '%d 天', M: '1 个月', MM: '%d 个月', y: '1 年', yy: '%d 年' }, meridiem: (hour, minute) => { const hm = (hour * 100) + minute if (hm < 600) { return '凌晨' } else if (hm < 900) { return '早上' } else if (hm < 1100) { return '上午' } else if (hm < 1300) { return '中午' } else if (hm < 1800) { return '下午' } return '晚上' } } dayjs.locale(locale, null, true) export default locale ================================================ FILE: src/plugin/advancedFormat/index.js ================================================ import { FORMAT_DEFAULT } from '../../constant' export default (o, c) => { // locale needed later const proto = c.prototype const oldFormat = proto.format proto.format = function (formatStr) { const locale = this.$locale() if (!this.isValid()) { return oldFormat.bind(this)(formatStr) } const utils = this.$utils() const str = formatStr || FORMAT_DEFAULT const result = str.replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, (match) => { switch (match) { case 'Q': return Math.ceil((this.$M + 1) / 3) case 'Do': return locale.ordinal(this.$D) case 'gggg': return this.weekYear() case 'GGGG': return this.isoWeekYear() case 'wo': return locale.ordinal(this.week(), 'W') // W for week case 'w': case 'ww': return utils.s(this.week(), match === 'w' ? 1 : 2, '0') case 'W': case 'WW': return utils.s(this.isoWeek(), match === 'W' ? 1 : 2, '0') case 'k': case 'kk': return utils.s(String(this.$H === 0 ? 24 : this.$H), match === 'k' ? 1 : 2, '0') case 'X': return Math.floor(this.$d.getTime() / 1000) case 'x': return this.$d.getTime() case 'z': return `[${this.offsetName()}]` case 'zzz': return `[${this.offsetName('long')}]` default: return match } }) return oldFormat.bind(this)(result) } } ================================================ FILE: src/plugin/arraySupport/index.js ================================================ export default (o, c, dayjs) => { const proto = c.prototype const parseDate = (cfg) => { const { date, utc } = cfg if (Array.isArray(date)) { if (utc) { if (!date.length) { return new Date() } return new Date(Date.UTC.apply(null, date)) } if (date.length === 1) { return dayjs(String(date[0])).toDate() } return new (Function.prototype.bind.apply(Date, [null].concat(date)))() } return date } const oldParse = proto.parse proto.parse = function (cfg) { cfg.date = parseDate.bind(this)(cfg) oldParse.bind(this)(cfg) } } ================================================ FILE: src/plugin/badMutable/index.js ================================================ export default (o, c) => { // locale needed later const proto = c.prototype proto.$g = function (input, get, set) { if (this.$utils().u(input)) return this[get] return this.$set(set, input) } proto.set = function (string, int) { return this.$set(string, int) } const oldStartOf = proto.startOf proto.startOf = function (units, startOf) { this.$d = oldStartOf.bind(this)(units, startOf).toDate() this.init() return this } const oldAdd = proto.add proto.add = function (number, units) { this.$d = oldAdd.bind(this)(number, units).toDate() this.init() return this } const oldLocale = proto.locale proto.locale = function (preset, object) { if (!preset) return this.$L this.$L = oldLocale.bind(this)(preset, object).$L return this } const oldDaysInMonth = proto.daysInMonth proto.daysInMonth = function () { return oldDaysInMonth.bind(this.clone())() } const oldIsSame = proto.isSame proto.isSame = function (that, units) { return oldIsSame.bind(this.clone())(that, units) } const oldIsBefore = proto.isBefore proto.isBefore = function (that, units) { return oldIsBefore.bind(this.clone())(that, units) } const oldIsAfter = proto.isAfter proto.isAfter = function (that, units) { return oldIsAfter.bind(this.clone())(that, units) } } ================================================ FILE: src/plugin/bigIntSupport/index.js ================================================ // eslint-disable-next-line valid-typeof const isBigInt = num => typeof num === 'bigint' export default (o, c, dayjs) => { const proto = c.prototype const parseDate = (cfg) => { const { date } = cfg if (isBigInt(date)) { return Number(date) } return date } const oldParse = proto.parse proto.parse = function (cfg) { cfg.date = parseDate.bind(this)(cfg) oldParse.bind(this)(cfg) } const oldUnix = dayjs.unix dayjs.unix = function (timestamp) { const ts = isBigInt(timestamp) ? Number(timestamp) : timestamp return oldUnix(ts) } } ================================================ FILE: src/plugin/buddhistEra/index.js ================================================ import { FORMAT_DEFAULT } from '../../constant' export default (o, c) => { // locale needed later const proto = c.prototype const oldFormat = proto.format // extend en locale here proto.format = function (formatStr) { const yearBias = 543 const str = formatStr || FORMAT_DEFAULT const result = str.replace(/(\[[^\]]+])|BBBB|BB/g, (match, a) => { const year = String(this.$y + yearBias) const args = match === 'BB' ? [year.slice(-2), 2] : [year, 4] return a || this.$utils().s(...args, '0') }) return oldFormat.bind(this)(result) } } ================================================ FILE: src/plugin/calendar/index.js ================================================ export default (o, c, d) => { const LT = 'h:mm A' const L = 'MM/DD/YYYY' const calendarFormat = { lastDay: `[Yesterday at] ${LT}`, sameDay: `[Today at] ${LT}`, nextDay: `[Tomorrow at] ${LT}`, nextWeek: `dddd [at] ${LT}`, lastWeek: `[Last] dddd [at] ${LT}`, sameElse: L } const proto = c.prototype proto.calendar = function (referenceTime, formats) { const format = formats || this.$locale().calendar || calendarFormat const referenceStartOfDay = d(referenceTime || undefined).startOf('d') const diff = this.diff(referenceStartOfDay, 'd', true) const sameElse = 'sameElse' /* eslint-disable no-nested-ternary */ const retVal = diff < -6 ? sameElse : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : sameElse /* eslint-enable no-nested-ternary */ const currentFormat = format[retVal] || calendarFormat[retVal] if (typeof currentFormat === 'function') { return currentFormat.call(this, d()) } return this.format(currentFormat) } } ================================================ FILE: src/plugin/customParseFormat/index.js ================================================ import { u } from '../localizedFormat/utils' const formattingTokens = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g const match1 = /\d/ // 0 - 9 const match2 = /\d\d/ // 00 - 99 const match3 = /\d{3}/ // 000 - 999 const match4 = /\d{4}/ // 0000 - 9999 const match1to2 = /\d\d?/ // 0 - 99 const matchSigned = /[+-]?\d+/ // -inf - inf const matchOffset = /[+-]\d\d:?(\d\d)?|Z/ // +00:00 -00:00 +0000 or -0000 +00 or Z const matchWord = /\d*[^-_:/,()\s\d]+/ // Word let locale = {} let parseTwoDigitYear = function (input) { input = +input return input + (input > 68 ? 1900 : 2000) } function offsetFromString(string) { if (!string) return 0 if (string === 'Z') return 0 const parts = string.match(/([+-]|\d\d)/g) const minutes = +(parts[1] * 60) + (+parts[2] || 0) return minutes === 0 ? 0 : parts[0] === '+' ? -minutes : minutes // eslint-disable-line no-nested-ternary } const addInput = function (property) { return function (input) { this[property] = +input } } const zoneExpressions = [matchOffset, function (input) { const zone = this.zone || (this.zone = {}) zone.offset = offsetFromString(input) }] const getLocalePart = (name) => { const part = locale[name] return part && ( part.indexOf ? part : part.s.concat(part.f) ) } const meridiemMatch = (input, isLowerCase) => { let isAfternoon const { meridiem } = locale if (!meridiem) { isAfternoon = input === (isLowerCase ? 'pm' : 'PM') } else { for (let i = 1; i <= 24; i += 1) { // todo: fix input === meridiem(i, 0, isLowerCase) if (input.indexOf(meridiem(i, 0, isLowerCase)) > -1) { isAfternoon = i > 12 break } } } return isAfternoon } const expressions = { A: [matchWord, function (input) { this.afternoon = meridiemMatch(input, false) }], a: [matchWord, function (input) { this.afternoon = meridiemMatch(input, true) }], Q: [match1, function (input) { this.month = ((input - 1) * 3) + 1 }], S: [match1, function (input) { this.milliseconds = +input * 100 }], SS: [match2, function (input) { this.milliseconds = +input * 10 }], SSS: [match3, function (input) { this.milliseconds = +input }], s: [match1to2, addInput('seconds')], ss: [match1to2, addInput('seconds')], m: [match1to2, addInput('minutes')], mm: [match1to2, addInput('minutes')], H: [match1to2, addInput('hours')], h: [match1to2, addInput('hours')], HH: [match1to2, addInput('hours')], hh: [match1to2, addInput('hours')], D: [match1to2, addInput('day')], DD: [match2, addInput('day')], Do: [matchWord, function (input) { const { ordinal } = locale; [this.day] = input.match(/\d+/) if (!ordinal) return for (let i = 1; i <= 31; i += 1) { if (ordinal(i).replace(/\[|\]/g, '') === input) { this.day = i } } }], w: [match1to2, addInput('week')], ww: [match2, addInput('week')], M: [match1to2, addInput('month')], MM: [match2, addInput('month')], MMM: [matchWord, function (input) { const months = getLocalePart('months') const monthsShort = getLocalePart('monthsShort') const matchIndex = (monthsShort || months.map(_ => _.slice(0, 3))).indexOf(input) + 1 if (matchIndex < 1) { throw new Error() } this.month = (matchIndex % 12) || matchIndex }], MMMM: [matchWord, function (input) { const months = getLocalePart('months') const matchIndex = months.indexOf(input) + 1 if (matchIndex < 1) { throw new Error() } this.month = (matchIndex % 12) || matchIndex }], Y: [matchSigned, addInput('year')], YY: [match2, function (input) { this.year = parseTwoDigitYear(input) }], YYYY: [match4, addInput('year')], Z: zoneExpressions, ZZ: zoneExpressions } function correctHours(time) { const { afternoon } = time if (afternoon !== undefined) { const { hours } = time if (afternoon) { if (hours < 12) { time.hours += 12 } } else if (hours === 12) { time.hours = 0 } delete time.afternoon } } function makeParser(format) { format = u(format, locale && locale.formats) const array = format.match(formattingTokens) const { length } = array for (let i = 0; i < length; i += 1) { const token = array[i] const parseTo = expressions[token] const regex = parseTo && parseTo[0] const parser = parseTo && parseTo[1] if (parser) { array[i] = { regex, parser } } else { array[i] = token.replace(/^\[|\]$/g, '') } } return function (input) { const time = {} for (let i = 0, start = 0; i < length; i += 1) { const token = array[i] if (typeof token === 'string') { start += token.length } else { const { regex, parser } = token const part = input.slice(start) const match = regex.exec(part) const value = match[0] parser.call(time, value) input = input.replace(value, '') } } correctHours(time) return time } } const parseFormattedInput = (input, format, utc, dayjs) => { try { if (['x', 'X'].indexOf(format) > -1) return new Date((format === 'X' ? 1000 : 1) * input) const parser = makeParser(format) const { year, month, day, hours, minutes, seconds, milliseconds, zone, week } = parser(input) const now = new Date() const d = day || ((!year && !month) ? now.getDate() : 1) const y = year || now.getFullYear() let M = 0 if (!(year && !month)) { M = month > 0 ? month - 1 : now.getMonth() } const h = hours || 0 const m = minutes || 0 const s = seconds || 0 const ms = milliseconds || 0 if (zone) { return new Date(Date.UTC(y, M, d, h, m, s, ms + (zone.offset * 60 * 1000))) } if (utc) { return new Date(Date.UTC(y, M, d, h, m, s, ms)) } let newDate newDate = new Date(y, M, d, h, m, s, ms) if (week) { newDate = dayjs(newDate).week(week).toDate() } return newDate } catch (e) { return new Date('') // Invalid Date } } export default (o, C, d) => { d.p.customParseFormat = true if (o && o.parseTwoDigitYear) { ({ parseTwoDigitYear } = o) } const proto = C.prototype const oldParse = proto.parse proto.parse = function (cfg) { const { date, utc, args } = cfg this.$u = utc const format = args[1] if (typeof format === 'string') { const isStrictWithoutLocale = args[2] === true const isStrictWithLocale = args[3] === true const isStrict = isStrictWithoutLocale || isStrictWithLocale let pl = args[2] if (isStrictWithLocale) [, , pl] = args locale = this.$locale() if (!isStrictWithoutLocale && pl) { locale = d.Ls[pl] } this.$d = parseFormattedInput(date, format, utc, d) this.init() if (pl && pl !== true) this.$L = this.locale(pl).$L // use != to treat // input number 1410715640579 and format string '1410715640579' equal // eslint-disable-next-line eqeqeq if (isStrict && date != this.format(format)) { this.$d = new Date('') } // reset global locale to make parallel unit test locale = {} } else if (format instanceof Array) { const len = format.length for (let i = 1; i <= len; i += 1) { args[1] = format[i - 1] const result = d.apply(this, args) if (result.isValid()) { this.$d = result.$d this.$L = result.$L this.init() break } if (i === len) this.$d = new Date('') } } else { oldParse.call(this, cfg) } } } ================================================ FILE: src/plugin/dayOfYear/index.js ================================================ export default (o, c, d) => { const proto = c.prototype proto.dayOfYear = function (input) { // d(this) is for badMutable const dayOfYear = Math.round((d(this).startOf('day') - d(this).startOf('year')) / 864e5) + 1 return input == null ? dayOfYear : this.add(input - dayOfYear, 'day') } } ================================================ FILE: src/plugin/devHelper/index.js ================================================ /* eslint-disable no-console */ export default (o, c, d) => { /* istanbul ignore next line */ if (!process || process.env.NODE_ENV !== 'production') { const proto = c.prototype const oldParse = proto.parse proto.parse = function (cfg) { const { date } = cfg if (typeof date === 'string' && date.length === 13) { console.warn(`To parse a Unix timestamp like ${date}, you should pass it as a Number. https://day.js.org/docs/en/parse/unix-timestamp-milliseconds`) } if (typeof date === 'number' && String(date).length === 4) { console.warn(`Guessing you may want to parse the Year ${date}, you should pass it as a String ${date}, not a Number. Otherwise, ${date} will be treated as a Unix timestamp`) } if (cfg.args.length >= 2 && !d.p.customParseFormat) { console.warn(`To parse a date-time string like ${date} using the given format, you should enable customParseFormat plugin first. https://day.js.org/docs/en/parse/string-format`) } return oldParse.bind(this)(cfg) } const oldLocale = d.locale d.locale = function (preset, object, isLocal) { if (typeof object === 'undefined' && typeof preset === 'string') { if (!d.Ls[preset]) { console.warn(`Guessing you may want to use locale ${preset}, you have to load it before using it. https://day.js.org/docs/en/i18n/loading-into-nodejs`) } } return oldLocale(preset, object, isLocal) } const oldDiff = proto.diff proto.diff = function (date, unit, float) { const isInvalidDate = !date || !d(date).isValid() if (isInvalidDate) { console.warn('Invalid usage: diff() requires a valid comparison date as the first argument. https://day.js.org/docs/en/display/difference') } return oldDiff.call(this, date, unit, float) } } } ================================================ FILE: src/plugin/duration/index.js ================================================ import { MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK } from '../../constant' const MILLISECONDS_A_YEAR = MILLISECONDS_A_DAY * 365 const MILLISECONDS_A_MONTH = MILLISECONDS_A_YEAR / 12 const DURATION_REGEX_PARSE = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/ const DURATION_REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY|Y|M{1,2}|D{1,2}|H{1,2}|m{1,2}|s{1,2}|SSS/g const unitToMS = { years: MILLISECONDS_A_YEAR, months: MILLISECONDS_A_MONTH, days: MILLISECONDS_A_DAY, hours: MILLISECONDS_A_HOUR, minutes: MILLISECONDS_A_MINUTE, seconds: MILLISECONDS_A_SECOND, milliseconds: 1, weeks: MILLISECONDS_A_WEEK } const isDuration = d => d instanceof Duration // eslint-disable-line no-use-before-define let $d let $u const wrapper = (input, instance, unit) => new Duration(input, unit, instance.$l) // eslint-disable-line no-use-before-define const prettyUnit = unit => `${$u.p(unit)}s` const isNegative = number => number < 0 const roundNumber = number => (isNegative(number) ? Math.ceil(number) : Math.floor(number)) const absolute = number => Math.abs(number) const getNumberUnitFormat = (number, unit) => { if (!number) { return { negative: false, format: '' } } if (isNegative(number)) { return { negative: true, format: `${absolute(number)}${unit}` } } return { negative: false, format: `${number}${unit}` } } class Duration { constructor(input, unit, locale) { this.$d = {} this.$l = locale if (input === undefined) { this.$ms = 0 this.parseFromMilliseconds() } if (unit) { return wrapper(input * unitToMS[prettyUnit(unit)], this) } if (typeof input === 'number') { this.$ms = input this.parseFromMilliseconds() return this } if (typeof input === 'object') { Object.keys(input).forEach((k) => { this.$d[prettyUnit(k)] = input[k] }) this.calMilliseconds() return this } if (typeof input === 'string') { const d = input.match(DURATION_REGEX_PARSE) if (d) { const properties = d.slice(2) const numberD = properties.map(value => (value != null ? Number(value) : 0)); [ this.$d.years, this.$d.months, this.$d.weeks, this.$d.days, this.$d.hours, this.$d.minutes, this.$d.seconds ] = numberD this.calMilliseconds() return this } } return this } calMilliseconds() { this.$ms = Object.keys(this.$d).reduce((total, unit) => ( total + ((this.$d[unit] || 0) * (unitToMS[unit])) ), 0) } parseFromMilliseconds() { let { $ms } = this this.$d.years = roundNumber($ms / MILLISECONDS_A_YEAR) $ms %= MILLISECONDS_A_YEAR this.$d.months = roundNumber($ms / MILLISECONDS_A_MONTH) $ms %= MILLISECONDS_A_MONTH this.$d.days = roundNumber($ms / MILLISECONDS_A_DAY) $ms %= MILLISECONDS_A_DAY this.$d.hours = roundNumber($ms / MILLISECONDS_A_HOUR) $ms %= MILLISECONDS_A_HOUR this.$d.minutes = roundNumber($ms / MILLISECONDS_A_MINUTE) $ms %= MILLISECONDS_A_MINUTE this.$d.seconds = roundNumber($ms / MILLISECONDS_A_SECOND) $ms %= MILLISECONDS_A_SECOND this.$d.milliseconds = $ms } toISOString() { const Y = getNumberUnitFormat(this.$d.years, 'Y') const M = getNumberUnitFormat(this.$d.months, 'M') let days = +this.$d.days || 0 if (this.$d.weeks) { days += this.$d.weeks * 7 } const D = getNumberUnitFormat(days, 'D') const H = getNumberUnitFormat(this.$d.hours, 'H') const m = getNumberUnitFormat(this.$d.minutes, 'M') let seconds = this.$d.seconds || 0 if (this.$d.milliseconds) { seconds += this.$d.milliseconds / 1000 seconds = Math.round(seconds * 1000) / 1000 } const S = getNumberUnitFormat(seconds, 'S') const negativeMode = Y.negative || M.negative || D.negative || H.negative || m.negative || S.negative const T = H.format || m.format || S.format ? 'T' : '' const P = negativeMode ? '-' : '' const result = `${P}P${Y.format}${M.format}${D.format}${T}${H.format}${m.format}${S.format}` return result === 'P' || result === '-P' ? 'P0D' : result } toJSON() { return this.toISOString() } format(formatStr) { const str = formatStr || 'YYYY-MM-DDTHH:mm:ss' const matches = { Y: this.$d.years, YY: $u.s(this.$d.years, 2, '0'), YYYY: $u.s(this.$d.years, 4, '0'), M: this.$d.months, MM: $u.s(this.$d.months, 2, '0'), D: this.$d.days, DD: $u.s(this.$d.days, 2, '0'), H: this.$d.hours, HH: $u.s(this.$d.hours, 2, '0'), m: this.$d.minutes, mm: $u.s(this.$d.minutes, 2, '0'), s: this.$d.seconds, ss: $u.s(this.$d.seconds, 2, '0'), SSS: $u.s(this.$d.milliseconds, 3, '0') } return str.replace(DURATION_REGEX_FORMAT, (match, $1) => $1 || String(matches[match])) } as(unit) { return this.$ms / (unitToMS[prettyUnit(unit)]) } get(unit) { let base = this.$ms const pUnit = prettyUnit(unit) if (pUnit === 'milliseconds') { base %= 1000 } else if (pUnit === 'weeks') { base = roundNumber(base / unitToMS[pUnit]) } else { base = this.$d[pUnit] } return base || 0 // a === 0 will be true on both 0 and -0 } add(input, unit, isSubtract) { let another if (unit) { another = input * unitToMS[prettyUnit(unit)] } else if (isDuration(input)) { another = input.$ms } else { another = wrapper(input, this).$ms } return wrapper(this.$ms + (another * (isSubtract ? -1 : 1)), this) } subtract(input, unit) { return this.add(input, unit, true) } locale(l) { const that = this.clone() that.$l = l return that } clone() { return wrapper(this.$ms, this) } humanize(withSuffix) { return $d() .add(this.$ms, 'ms') .locale(this.$l) .fromNow(!withSuffix) } valueOf() { return this.asMilliseconds() } milliseconds() { return this.get('milliseconds') } asMilliseconds() { return this.as('milliseconds') } seconds() { return this.get('seconds') } asSeconds() { return this.as('seconds') } minutes() { return this.get('minutes') } asMinutes() { return this.as('minutes') } hours() { return this.get('hours') } asHours() { return this.as('hours') } days() { return this.get('days') } asDays() { return this.as('days') } weeks() { return this.get('weeks') } asWeeks() { return this.as('weeks') } months() { return this.get('months') } asMonths() { return this.as('months') } years() { return this.get('years') } asYears() { return this.as('years') } } const manipulateDuration = (date, duration, k) => date.add(duration.years() * k, 'y') .add(duration.months() * k, 'M') .add(duration.days() * k, 'd') .add(duration.hours() * k, 'h') .add(duration.minutes() * k, 'm') .add(duration.seconds() * k, 's') .add(duration.milliseconds() * k, 'ms') export default (option, Dayjs, dayjs) => { $d = dayjs $u = dayjs().$utils() dayjs.duration = function (input, unit) { const $l = dayjs.locale() return wrapper(input, { $l }, unit) } dayjs.isDuration = isDuration const oldAdd = Dayjs.prototype.add const oldSubtract = Dayjs.prototype.subtract Dayjs.prototype.add = function (value, unit) { if (isDuration(value)) { return manipulateDuration(this, value, 1) } return oldAdd.bind(this)(value, unit) } Dayjs.prototype.subtract = function (value, unit) { if (isDuration(value)) { return manipulateDuration(this, value, -1) } return oldSubtract.bind(this)(value, unit) } } ================================================ FILE: src/plugin/isBetween/index.js ================================================ export default (o, c, d) => { c.prototype.isBetween = function (a, b, u, i) { const dA = d(a) const dB = d(b) i = i || '()' const dAi = i[0] === '(' const dBi = i[1] === ')' return ((dAi ? this.isAfter(dA, u) : !this.isBefore(dA, u)) && (dBi ? this.isBefore(dB, u) : !this.isAfter(dB, u))) || ((dAi ? this.isBefore(dA, u) : !this.isAfter(dA, u)) && (dBi ? this.isAfter(dB, u) : !this.isBefore(dB, u))) } } ================================================ FILE: src/plugin/isLeapYear/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.isLeapYear = function () { return ((this.$y % 4 === 0) && (this.$y % 100 !== 0)) || (this.$y % 400 === 0) } } ================================================ FILE: src/plugin/isMoment/index.js ================================================ export default (o, c, f) => { f.isMoment = function (input) { return f.isDayjs(input) } } ================================================ FILE: src/plugin/isSameOrAfter/index.js ================================================ export default (o, c) => { c.prototype.isSameOrAfter = function (that, units) { return this.isSame(that, units) || this.isAfter(that, units) } } ================================================ FILE: src/plugin/isSameOrBefore/index.js ================================================ export default (o, c) => { c.prototype.isSameOrBefore = function (that, units) { return this.isSame(that, units) || this.isBefore(that, units) } } ================================================ FILE: src/plugin/isToday/index.js ================================================ export default (o, c, d) => { const proto = c.prototype proto.isToday = function () { const comparisonTemplate = 'YYYY-MM-DD' const now = d() return this.format(comparisonTemplate) === now.format(comparisonTemplate) } } ================================================ FILE: src/plugin/isTomorrow/index.js ================================================ export default (o, c, d) => { const proto = c.prototype proto.isTomorrow = function () { const comparisonTemplate = 'YYYY-MM-DD' const tomorrow = d().add(1, 'day') return ( this.format(comparisonTemplate) === tomorrow.format(comparisonTemplate) ) } } ================================================ FILE: src/plugin/isYesterday/index.js ================================================ export default (o, c, d) => { const proto = c.prototype proto.isYesterday = function () { const comparisonTemplate = 'YYYY-MM-DD' const yesterday = d().subtract(1, 'day') return ( this.format(comparisonTemplate) === yesterday.format(comparisonTemplate) ) } } ================================================ FILE: src/plugin/isoWeek/index.js ================================================ import { D, W, Y } from '../../constant' const isoWeekPrettyUnit = 'isoweek' export default (o, c, d) => { const getYearFirstThursday = (year, isUtc) => { const yearFirstDay = (isUtc ? d.utc : d)().year(year).startOf(Y) let addDiffDays = 4 - yearFirstDay.isoWeekday() if (yearFirstDay.isoWeekday() > 4) { addDiffDays += 7 } return yearFirstDay.add(addDiffDays, D) } const getCurrentWeekThursday = ins => ins.add((4 - ins.isoWeekday()), D) const proto = c.prototype proto.isoWeekYear = function () { const nowWeekThursday = getCurrentWeekThursday(this) return nowWeekThursday.year() } proto.isoWeek = function (week) { if (!this.$utils().u(week)) { return this.add((week - this.isoWeek()) * 7, D) } const nowWeekThursday = getCurrentWeekThursday(this) const diffWeekThursday = getYearFirstThursday(this.isoWeekYear(), this.$u) return nowWeekThursday.diff(diffWeekThursday, W) + 1 } proto.isoWeekday = function (week) { if (!this.$utils().u(week)) { return this.day(this.day() % 7 ? week : week - 7) } return this.day() || 7 } const oldStartOf = proto.startOf proto.startOf = function (units, startOf) { const utils = this.$utils() const isStartOf = !utils.u(startOf) ? startOf : true const unit = utils.p(units) if (unit === isoWeekPrettyUnit) { return isStartOf ? this.date(this.date() - (this.isoWeekday() - 1)).startOf('day') : this.date((this.date() - 1 - (this.isoWeekday() - 1)) + 7).endOf('day') } return oldStartOf.bind(this)(units, startOf) } } ================================================ FILE: src/plugin/isoWeeksInYear/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.isoWeeksInYear = function () { const isLeapYear = this.isLeapYear() const last = this.endOf('y') const day = last.day() if (day === 4 || (isLeapYear && day === 5)) { return 53 } return 52 } } ================================================ FILE: src/plugin/localeData/index.js ================================================ import { t } from '../localizedFormat/utils' export default (o, c, dayjs) => { // locale needed later const proto = c.prototype const getLocalePart = part => (part && (part.indexOf ? part : part.s)) const getShort = (ins, target, full, num, localeOrder) => { const locale = ins.name ? ins : ins.$locale() const targetLocale = getLocalePart(locale[target]) const fullLocale = getLocalePart(locale[full]) const result = targetLocale || fullLocale.map(f => f.slice(0, num)) if (!localeOrder) return result const { weekStart } = locale return result.map((_, index) => (result[(index + (weekStart || 0)) % 7])) } const getDayjsLocaleObject = () => dayjs.Ls[dayjs.locale()] const getLongDateFormat = (l, format) => l.formats[format] || t(l.formats[format.toUpperCase()]) const localeData = function () { return { months: instance => (instance ? instance.format('MMMM') : getShort(this, 'months')), monthsShort: instance => (instance ? instance.format('MMM') : getShort(this, 'monthsShort', 'months', 3)), firstDayOfWeek: () => this.$locale().weekStart || 0, weekdays: instance => (instance ? instance.format('dddd') : getShort(this, 'weekdays')), weekdaysMin: instance => (instance ? instance.format('dd') : getShort(this, 'weekdaysMin', 'weekdays', 2)), weekdaysShort: instance => (instance ? instance.format('ddd') : getShort(this, 'weekdaysShort', 'weekdays', 3)), longDateFormat: format => getLongDateFormat(this.$locale(), format), meridiem: this.$locale().meridiem, ordinal: this.$locale().ordinal } } proto.localeData = function () { return localeData.bind(this)() } dayjs.localeData = () => { const localeObject = getDayjsLocaleObject() return { firstDayOfWeek: () => localeObject.weekStart || 0, weekdays: () => dayjs.weekdays(), weekdaysShort: () => dayjs.weekdaysShort(), weekdaysMin: () => dayjs.weekdaysMin(), months: () => dayjs.months(), monthsShort: () => dayjs.monthsShort(), longDateFormat: format => getLongDateFormat(localeObject, format), meridiem: localeObject.meridiem, ordinal: localeObject.ordinal } } dayjs.months = () => getShort(getDayjsLocaleObject(), 'months') dayjs.monthsShort = () => getShort(getDayjsLocaleObject(), 'monthsShort', 'months', 3) dayjs.weekdays = localeOrder => getShort(getDayjsLocaleObject(), 'weekdays', null, null, localeOrder) dayjs.weekdaysShort = localeOrder => getShort(getDayjsLocaleObject(), 'weekdaysShort', 'weekdays', 3, localeOrder) dayjs.weekdaysMin = localeOrder => getShort(getDayjsLocaleObject(), 'weekdaysMin', 'weekdays', 2, localeOrder) } ================================================ FILE: src/plugin/localizedFormat/index.js ================================================ import { FORMAT_DEFAULT } from '../../constant' import { u, englishFormats } from './utils' export default (o, c, d) => { const proto = c.prototype const oldFormat = proto.format d.en.formats = englishFormats proto.format = function (formatStr = FORMAT_DEFAULT) { const { formats = {} } = this.$locale() const result = u(formatStr, formats) return oldFormat.call(this, result) } } ================================================ FILE: src/plugin/localizedFormat/utils.js ================================================ // eslint-disable-next-line import/prefer-default-export export const t = format => format.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1)) export const englishFormats = { LTS: 'h:mm:ss A', LT: 'h:mm A', L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', LLLL: 'dddd, MMMM D, YYYY h:mm A' } export const u = (formatStr, formats) => formatStr.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => { const B = b && b.toUpperCase() return a || formats[b] || englishFormats[b] || t(formats[B]) }) ================================================ FILE: src/plugin/minMax/index.js ================================================ export default (o, c, d) => { const sortBy = (method, dates) => { if ( !dates || !dates.length || (dates.length === 1 && !dates[0]) || (dates.length === 1 && Array.isArray(dates[0]) && !dates[0].length) ) { return null } if (dates.length === 1 && dates[0].length > 0) { [dates] = dates } dates = dates.filter(date => date) let result; [result] = dates for (let i = 1; i < dates.length; i += 1) { if (!dates[i].isValid() || dates[i][method](result)) { result = dates[i] } } return result } d.max = function () { const args = [].slice.call(arguments, 0) // eslint-disable-line prefer-rest-params return sortBy('isAfter', args) } d.min = function () { const args = [].slice.call(arguments, 0) // eslint-disable-line prefer-rest-params return sortBy('isBefore', args) } } ================================================ FILE: src/plugin/negativeYear/index.js ================================================ export default (_, c, dayjs) => { const proto = c.prototype const parseDate = (cfg) => { const { date, utc } = cfg if (typeof date === 'string' && date.charAt(0) === '-') { const normalData = date.slice(1) let newDate = dayjs(normalData) if (utc) { newDate = dayjs.utc(normalData) } else { newDate = dayjs(normalData) } const fullYear = newDate.year() if (date.indexOf(`-${fullYear}`) !== -1) { return dayjs(newDate).subtract(fullYear * 2, 'year').toDate() } return date } return date } const oldParse = proto.parse proto.parse = function (cfg) { cfg.date = parseDate.bind(this)(cfg) oldParse.bind(this)(cfg) } } ================================================ FILE: src/plugin/objectSupport/index.js ================================================ export default (o, c, dayjs) => { const proto = c.prototype const isObject = obj => obj !== null && !(obj instanceof Date) && !(obj instanceof Array) && !proto.$utils().u(obj) && (obj.constructor.name === 'Object') const prettyUnit = (u) => { const unit = proto.$utils().p(u) return unit === 'date' ? 'day' : unit } const parseDate = (cfg) => { const { date, utc } = cfg const $d = {} if (isObject(date)) { if (!Object.keys(date).length) { return new Date() } const now = utc ? dayjs.utc() : dayjs() Object.keys(date).forEach((k) => { $d[prettyUnit(k)] = date[k] }) const d = $d.day || ((!$d.year && !($d.month >= 0)) ? now.date() : 1) const y = $d.year || now.year() const M = $d.month >= 0 ? $d.month : ((!$d.year && !$d.day) ? now.month() : 0)// eslint-disable-line no-nested-ternary,max-len const h = $d.hour || 0 const m = $d.minute || 0 const s = $d.second || 0 const ms = $d.millisecond || 0 if (utc) { return new Date(Date.UTC(y, M, d, h, m, s, ms)) } return new Date(y, M, d, h, m, s, ms) } return date } const oldParse = proto.parse proto.parse = function (cfg) { cfg.date = parseDate.bind(this)(cfg) oldParse.bind(this)(cfg) } const oldSet = proto.set const oldAdd = proto.add const oldSubtract = proto.subtract const callObject = function (call, argument, string, offset = 1) { const keys = Object.keys(argument) let chain = this keys.forEach((key) => { chain = call.bind(chain)(argument[key] * offset, key) }) return chain } proto.set = function (unit, value) { value = value === undefined ? unit : value if (unit.constructor.name === 'Object') { return callObject.bind(this)(function (i, s) { return oldSet.bind(this)(s, i) }, value, unit) } return oldSet.bind(this)(unit, value) } proto.add = function (value, unit) { if (value.constructor.name === 'Object') { return callObject.bind(this)(oldAdd, value, unit) } return oldAdd.bind(this)(value, unit) } proto.subtract = function (value, unit) { if (value.constructor.name === 'Object') { return callObject.bind(this)(oldAdd, value, unit, -1) } return oldSubtract.bind(this)(value, unit) } } ================================================ FILE: src/plugin/pluralGetSet/index.js ================================================ export default (o, c) => { const proto = c.prototype const pluralAliases = [ 'milliseconds', 'seconds', 'minutes', 'hours', 'days', 'weeks', 'isoWeeks', 'months', 'quarters', 'years', 'dates' ] pluralAliases.forEach((alias) => { proto[alias] = proto[alias.replace(/s$/, '')] }) } ================================================ FILE: src/plugin/preParsePostFormat/index.js ================================================ // Plugin template from https://day.js.org/docs/en/plugin/plugin export default (option, dayjsClass) => { const oldParse = dayjsClass.prototype.parse dayjsClass.prototype.parse = function (cfg) { if (typeof cfg.date === 'string') { const locale = this.$locale() cfg.date = locale && locale.preparse ? locale.preparse(cfg.date) : cfg.date } // original parse result return oldParse.bind(this)(cfg) } // // overriding existing API // // e.g. extend dayjs().format() const oldFormat = dayjsClass.prototype.format dayjsClass.prototype.format = function (...args) { // original format result const result = oldFormat.call(this, ...args) // return modified result const locale = this.$locale() return locale && locale.postformat ? locale.postformat(result) : result } const oldFromTo = dayjsClass.prototype.fromToBase if (oldFromTo) { dayjsClass.prototype.fromToBase = function ( input, withoutSuffix, instance, isFrom ) { const locale = this.$locale() || instance.$locale() // original format result return oldFromTo.call( this, input, withoutSuffix, instance, isFrom, locale && locale.postformat ) } } } ================================================ FILE: src/plugin/quarterOfYear/index.js ================================================ import { Q, M, D } from '../../constant' export default (o, c) => { const proto = c.prototype proto.quarter = function (quarter) { if (!this.$utils().u(quarter)) { return this.month((this.month() % 3) + ((quarter - 1) * 3)) } return Math.ceil((this.month() + 1) / 3) } const oldAdd = proto.add proto.add = function (number, units) { number = Number(number) // eslint-disable-line no-param-reassign const unit = this.$utils().p(units) if (unit === Q) { return this.add(number * 3, M) } return oldAdd.bind(this)(number, units) } const oldStartOf = proto.startOf proto.startOf = function (units, startOf) { const utils = this.$utils() const isStartOf = !utils.u(startOf) ? startOf : true const unit = utils.p(units) if (unit === Q) { const quarter = this.quarter() - 1 return isStartOf ? this.month(quarter * 3) .startOf(M).startOf(D) : this.month((quarter * 3) + 2).endOf(M).endOf(D) } return oldStartOf.bind(this)(units, startOf) } } ================================================ FILE: src/plugin/relativeTime/index.js ================================================ import * as C from '../../constant' export default (o, c, d) => { o = o || {} const proto = c.prototype const relObj = { future: 'in %s', past: '%s ago', s: 'a few seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } d.en.relativeTime = relObj proto.fromToBase = (input, withoutSuffix, instance, isFrom, postFormat) => { const loc = instance.$locale().relativeTime || relObj const T = o.thresholds || [ { l: 's', r: 44, d: C.S }, { l: 'm', r: 89 }, { l: 'mm', r: 44, d: C.MIN }, { l: 'h', r: 89 }, { l: 'hh', r: 21, d: C.H }, { l: 'd', r: 35 }, { l: 'dd', r: 25, d: C.D }, { l: 'M', r: 45 }, { l: 'MM', r: 10, d: C.M }, { l: 'y', r: 17 }, { l: 'yy', d: C.Y } ] const Tl = T.length let result let out let isFuture for (let i = 0; i < Tl; i += 1) { let t = T[i] if (t.d) { result = isFrom ? d(input).diff(instance, t.d, true) : instance.diff(input, t.d, true) } let abs = (o.rounding || Math.round)(Math.abs(result)) isFuture = result > 0 if (abs <= t.r || !t.r) { if (abs <= 1 && i > 0) t = T[i - 1] // 1 minutes -> a minute, 0 seconds -> 0 second const format = loc[t.l] if (postFormat) { abs = postFormat(`${abs}`) } if (typeof format === 'string') { out = format.replace('%d', abs) } else { out = format(abs, withoutSuffix, t.l, isFuture) } break } } if (withoutSuffix) return out const pastOrFuture = isFuture ? loc.future : loc.past if (typeof pastOrFuture === 'function') { return pastOrFuture(out) } return pastOrFuture.replace('%s', out) } function fromTo(input, withoutSuffix, instance, isFrom) { return proto.fromToBase(input, withoutSuffix, instance, isFrom) } proto.to = function (input, withoutSuffix) { return fromTo(input, withoutSuffix, this, true) } proto.from = function (input, withoutSuffix) { return fromTo(input, withoutSuffix, this) } const makeNow = thisDay => (thisDay.$u ? d.utc() : d()) proto.toNow = function (withoutSuffix) { return this.to(makeNow(this), withoutSuffix) } proto.fromNow = function (withoutSuffix) { return this.from(makeNow(this), withoutSuffix) } } ================================================ FILE: src/plugin/timezone/index.js ================================================ import { MIN, MS } from '../../constant' const typeToPos = { year: 0, month: 1, day: 2, hour: 3, minute: 4, second: 5 } // Cache time-zone lookups from Intl.DateTimeFormat, // as it is a *very* slow method. const dtfCache = {} const getDateTimeFormat = (timezone, options = {}) => { const timeZoneName = options.timeZoneName || 'short' const key = `${timezone}|${timeZoneName}` let dtf = dtfCache[key] if (!dtf) { dtf = new Intl.DateTimeFormat('en-US', { hour12: false, timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName }) dtfCache[key] = dtf } return dtf } export default (o, c, d) => { let defaultTimezone const makeFormatParts = (timestamp, timezone, options = {}) => { const date = new Date(timestamp) const dtf = getDateTimeFormat(timezone, options) return dtf.formatToParts(date) } const tzOffset = (timestamp, timezone) => { const formatResult = makeFormatParts(timestamp, timezone) const filled = [] for (let i = 0; i < formatResult.length; i += 1) { const { type, value } = formatResult[i] const pos = typeToPos[type] if (pos >= 0) { filled[pos] = parseInt(value, 10) } } const hour = filled[3] // Workaround for the same behavior in different node version // https://github.com/nodejs/node/issues/33027 /* istanbul ignore next */ const fixedHour = hour === 24 ? 0 : hour const utcString = `${filled[0]}-${filled[1]}-${filled[2]} ${fixedHour}:${filled[4]}:${filled[5]}:000` const utcTs = d.utc(utcString).valueOf() let asTS = +timestamp const over = asTS % 1000 asTS -= over return (utcTs - asTS) / (60 * 1000) } // find the right offset a given local time. The o input is our guess, which determines which // offset we'll pick in ambiguous cases (e.g. there are two 3 AMs b/c Fallback DST) // https://github.com/moment/luxon/blob/master/src/datetime.js#L76 const fixOffset = (localTS, o0, tz) => { // Our UTC time is just a guess because our offset is just a guess let utcGuess = localTS - (o0 * 60 * 1000) // Test whether the zone matches the offset for this ts const o2 = tzOffset(utcGuess, tz) // If so, offset didn't change and we're done if (o0 === o2) { return [utcGuess, o0] } // If not, change the ts by the difference in the offset utcGuess -= (o2 - o0) * 60 * 1000 // If that gives us the local time we want, we're done const o3 = tzOffset(utcGuess, tz) if (o2 === o3) { return [utcGuess, o2] } // If it's different, we're in a hole time. // The offset has changed, but the we don't adjust the time return [localTS - (Math.min(o2, o3) * 60 * 1000), Math.max(o2, o3)] } const proto = c.prototype proto.tz = function (timezone = defaultTimezone, keepLocalTime) { const oldOffset = this.utcOffset() const date = this.toDate() const target = date.toLocaleString('en-US', { timeZone: timezone }) const diff = Math.round((date - new Date(target)) / 1000 / 60) const offset = (-Math.round(date.getTimezoneOffset() / 15) * 15) - diff const isUTC = !Number(offset) let ins if (isUTC) { // if utcOffset is 0, turn it to UTC mode ins = this.utcOffset(0, keepLocalTime) } else { ins = d(target, { locale: this.$L }).$set(MS, this.$ms) .utcOffset(offset, true) if (keepLocalTime) { const newOffset = ins.utcOffset() ins = ins.add(oldOffset - newOffset, MIN) } } ins.$x.$timezone = timezone return ins } proto.offsetName = function (type) { // type: short(default) / long const zone = this.$x.$timezone || d.tz.guess() const result = makeFormatParts(this.valueOf(), zone, { timeZoneName: type }).find(m => m.type.toLowerCase() === 'timezonename') return result && result.value } const oldStartOf = proto.startOf proto.startOf = function (units, startOf) { if (!this.$x || !this.$x.$timezone) { return oldStartOf.call(this, units, startOf) } const withoutTz = d(this.format('YYYY-MM-DD HH:mm:ss:SSS'), { locale: this.$L }) const startOfWithoutTz = oldStartOf.call(withoutTz, units, startOf) return startOfWithoutTz.tz(this.$x.$timezone, true) } d.tz = function (input, arg1, arg2) { const parseFormat = arg2 && arg1 const timezone = arg2 || arg1 || defaultTimezone const previousOffset = tzOffset(+d(), timezone) if (typeof input !== 'string') { // timestamp number || js Date || Day.js return d(input).tz(timezone) } const localTs = d.utc(input, parseFormat).valueOf() const [targetTs, targetOffset] = fixOffset(localTs, previousOffset, timezone) const ins = d(targetTs).utcOffset(targetOffset) ins.$x.$timezone = timezone return ins } d.tz.guess = function () { return Intl.DateTimeFormat().resolvedOptions().timeZone } d.tz.setDefault = function (timezone) { defaultTimezone = timezone } } ================================================ FILE: src/plugin/toArray/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.toArray = function () { return [ this.$y, this.$M, this.$D, this.$H, this.$m, this.$s, this.$ms ] } } ================================================ FILE: src/plugin/toObject/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.toObject = function () { return { years: this.$y, months: this.$M, date: this.$D, hours: this.$H, minutes: this.$m, seconds: this.$s, milliseconds: this.$ms } } } ================================================ FILE: src/plugin/updateLocale/index.js ================================================ export default (option, Dayjs, dayjs) => { dayjs.updateLocale = function (locale, customConfig) { const localeList = dayjs.Ls const localeConfig = localeList[locale] if (!localeConfig) return const customConfigKeys = customConfig ? Object.keys(customConfig) : [] customConfigKeys.forEach((c) => { if (localeConfig[c] && customConfig[c] && typeof localeConfig[c] === 'object' && typeof customConfig[c] === 'object' && !Array.isArray(localeConfig[c])) { localeConfig[c] = { ...localeConfig[c], ...customConfig[c] } } else { localeConfig[c] = customConfig[c] } }) return localeConfig // eslint-disable-line consistent-return } } ================================================ FILE: src/plugin/utc/index.js ================================================ import { MILLISECONDS_A_MINUTE, MIN } from '../../constant' const REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g const REGEX_OFFSET_HOURS_MINUTES_FORMAT = /([+-]|\d\d)/g function offsetFromString(value = '') { const offset = value.match(REGEX_VALID_OFFSET_FORMAT) if (!offset) { return null } const [indicator, hoursOffset, minutesOffset] = `${offset[0]}`.match(REGEX_OFFSET_HOURS_MINUTES_FORMAT) || ['-', 0, 0] const totalOffsetInMinutes = (+hoursOffset * 60) + (+minutesOffset) if (totalOffsetInMinutes === 0) { return 0 } return indicator === '+' ? totalOffsetInMinutes : -totalOffsetInMinutes } export default (option, Dayjs, dayjs) => { const proto = Dayjs.prototype dayjs.utc = function (date) { const cfg = { date, utc: true, args: arguments } // eslint-disable-line prefer-rest-params return new Dayjs(cfg) // eslint-disable-line no-use-before-define } proto.utc = function (keepLocalTime) { const ins = dayjs(this.toDate(), { locale: this.$L, utc: true }) if (keepLocalTime) { return ins.add(this.utcOffset(), MIN) } return ins } proto.local = function () { return dayjs(this.toDate(), { locale: this.$L, utc: false }) } const oldParse = proto.parse proto.parse = function (cfg) { if (cfg.utc) { this.$u = true } if (!this.$utils().u(cfg.$offset)) { this.$offset = cfg.$offset } oldParse.call(this, cfg) } const oldInit = proto.init proto.init = function () { if (this.$u) { const { $d } = this this.$y = $d.getUTCFullYear() this.$M = $d.getUTCMonth() this.$D = $d.getUTCDate() this.$W = $d.getUTCDay() this.$H = $d.getUTCHours() this.$m = $d.getUTCMinutes() this.$s = $d.getUTCSeconds() this.$ms = $d.getUTCMilliseconds() } else { oldInit.call(this) } } const oldUtcOffset = proto.utcOffset proto.utcOffset = function (input, keepLocalTime) { const { u } = this.$utils() if (u(input)) { if (this.$u) { return 0 } if (!u(this.$offset)) { return this.$offset } return oldUtcOffset.call(this) } if (typeof input === 'string') { input = offsetFromString(input) if (input === null) { return this } } const offset = Math.abs(input) <= 16 ? input * 60 : input if (offset === 0) { return this.utc(keepLocalTime) } let ins = this.clone() if (keepLocalTime) { ins.$offset = offset ins.$u = false return ins } const localTimezoneOffset = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset() ins = this.local().add(offset + localTimezoneOffset, MIN) ins.$offset = offset ins.$x.$localOffset = localTimezoneOffset return ins } const oldFormat = proto.format const UTC_FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ss[Z]' proto.format = function (formatStr) { const str = formatStr || (this.$u ? UTC_FORMAT_DEFAULT : '') return oldFormat.call(this, str) } proto.valueOf = function () { const addedOffset = !this.$utils().u(this.$offset) ? this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()) : 0 return this.$d.valueOf() - (addedOffset * MILLISECONDS_A_MINUTE) } proto.isUTC = function () { return !!this.$u } proto.toISOString = function () { return this.toDate().toISOString() } proto.toString = function () { return this.toDate().toUTCString() } const oldToDate = proto.toDate proto.toDate = function (type) { if (type === 's' && this.$offset) { return dayjs(this.format('YYYY-MM-DD HH:mm:ss:SSS')).toDate() } return oldToDate.call(this) } const oldDiff = proto.diff proto.diff = function (input, units, float) { if (input && this.$u === input.$u) { return oldDiff.call(this, input, units, float) } const localThis = this.local() const localInput = dayjs(input).local() return oldDiff.call(localThis, localInput, units, float) } } ================================================ FILE: src/plugin/weekOfYear/index.js ================================================ import { MS, Y, D, W } from '../../constant' export default (o, c, d) => { const proto = c.prototype proto.week = function (week = null) { if (week !== null) { return this.add((week - this.week()) * 7, D) } const yearStart = this.$locale().yearStart || 1 if (this.month() === 11 && this.date() > 25) { // d(this) is for badMutable const nextYearStartDay = d(this).startOf(Y).add(1, Y).date(yearStart) const thisEndOfWeek = d(this).endOf(W) if (nextYearStartDay.isBefore(thisEndOfWeek)) { return 1 } } const yearStartDay = d(this).startOf(Y).date(yearStart) const yearStartWeek = yearStartDay.startOf(W).subtract(1, MS) const diffInWeek = this.diff(yearStartWeek, W, true) if (diffInWeek < 0) { return d(this).startOf('week').week() } return Math.ceil(diffInWeek) } proto.weeks = function (week = null) { return this.week(week) } } ================================================ FILE: src/plugin/weekYear/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.weekYear = function () { const month = this.month() const weekOfYear = this.week() const year = this.year() if (weekOfYear === 1 && month === 11) { return year + 1 } if (month === 0 && weekOfYear >= 52) { return year - 1 } return year } } ================================================ FILE: src/plugin/weekday/index.js ================================================ export default (o, c) => { const proto = c.prototype proto.weekday = function (input) { const weekStart = this.$locale().weekStart || 0 const { $W } = this const weekday = ($W < weekStart ? $W + 7 : $W) - weekStart if (this.$utils().u(input)) { return weekday } return this.subtract(weekday, 'day').add(input, 'day') } } ================================================ FILE: src/utils.js ================================================ import * as C from './constant' const padStart = (string, length, pad) => { const s = String(string) if (!s || s.length >= length) return string return `${Array((length + 1) - s.length).join(pad)}${string}` } const padZoneStr = (instance) => { const negMinutes = -instance.utcOffset() const minutes = Math.abs(negMinutes) const hourOffset = Math.floor(minutes / 60) const minuteOffset = minutes % 60 return `${negMinutes <= 0 ? '+' : '-'}${padStart(hourOffset, 2, '0')}:${padStart(minuteOffset, 2, '0')}` } const monthDiff = (a, b) => { // function from moment.js in order to keep the same result if (a.date() < b.date()) return -monthDiff(b, a) const wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()) const anchor = a.clone().add(wholeMonthDiff, C.M) const c = b - anchor < 0 const anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), C.M) return +(-(wholeMonthDiff + ((b - anchor) / (c ? (anchor - anchor2) : (anchor2 - anchor)))) || 0) } const absFloor = n => (n < 0 ? Math.ceil(n) || 0 : Math.floor(n)) const prettyUnit = (u) => { const special = { M: C.M, y: C.Y, w: C.W, d: C.D, D: C.DATE, h: C.H, m: C.MIN, s: C.S, ms: C.MS, Q: C.Q } return special[u] || String(u || '').toLowerCase().replace(/s$/, '') } const isUndefined = s => s === undefined export default { s: padStart, z: padZoneStr, m: monthDiff, a: absFloor, p: prettyUnit, u: isUndefined } ================================================ FILE: test/__mocks__/dayjs.js ================================================ const dayjs = require('../../src') module.exports = dayjs ================================================ FILE: test/browser.spec.js ================================================ /* eslint-disable prefer-arrow-callback,func-names */ // Please do NOT modify or change this file // Checkout our unit test files in test/*.test.js describe('Install', function () { it('window.dayjs ', function () { if (!window.dayjs) throw new Error('No window.dayjs') }) }) describe('Core APIs', function () { it('Chain Methods', function () { expect(dayjs('2011-02-05T14:48:00.000Z') .clone() .set('month', 3) .set('second', 30) .endOf('month') .startOf('week') .add(1, 'day') .subtract(1, 'year') .format('{YYYY} MM-DDTHH:mm:ss')).toBe('{2010} 04-25T00:00:00') }) it('Date parse - nonstandard date string', function () { expect(dayjs('2018-4-1 1:1:1:22').format('YYYY-MM-DD hh:mm:ss')) .toBe('2018-04-01 01:01:01') expect(dayjs('2018-4-1').format('YYYY-MM-DD hh:mm:ss')) .toBe('2018-04-01 12:00:00') expect(dayjs('2018-4-1 11:49').format('YYYY-MM-DD hh:mm:ss')) // fix ios bug .toBe('2018-04-01 11:49:00') }) }) ================================================ FILE: test/comparison.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../src' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) test('is same without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2012, 3, 2, 3, 5, 5, 10)))).toBe(false, 'year is later') expect(m.isSame(dayjs(new Date(2010, 3, 2, 3, 3, 5, 10)))).toBe(false, 'year is earlier') expect(m.isSame(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)))).toBe(false, 'month is later') expect(m.isSame(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)))).toBe(false, 'month is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)))).toBe(false, 'day is later') expect(m.isSame(dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)))).toBe(false, 'day is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)))).toBe(false, 'hour is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)))).toBe(false, 'hour is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)))).toBe(false, 'minute is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)))).toBe(false, 'minute is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)))).toBe(false, 'second is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 4, 11)))).toBe(false, 'second is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)))).toBe(true, 'millisecond match') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)))).toBe(false, 'millisecond is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)))).toBe(false, 'millisecond is earlier') expect(m.isSame(m)).toBe(true, 'moments are the same as themselves') expect(+m).toEqual(+mCopy, 'isSame second should not change moment') }) test('is same year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year match') expect(m.isSame(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year')).toBe(true, 'exact start of year') expect(m.isSame(dayjs(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'exact end of year') expect(m.isSame(dayjs(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year')).toBe(false, 'start of next year') expect(m.isSame(dayjs(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'end of previous year') expect(m.isSame(m, 'year')).toBe(true, 'same moments are in the same year') expect(+m).toEqual(+mCopy, 'isSame year should not change moment') }) test('is same month', () => { const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month match') expect(m.isSame(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month mismatch') expect(m.isSame(dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month')).toBe(true, 'exact start of month') expect(m.isSame(dayjs(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month')).toBe(true, 'exact end of month') expect(m.isSame(dayjs(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month')).toBe(false, 'start of next month') expect(m.isSame(dayjs(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month')).toBe(false, 'end of previous month') expect(m.isSame(m, 'month')).toBe(true, 'same moments are in the same month') expect(+m).toEqual(+mCopy, 'isSame month should not change moment') }) test('is same day', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'day match') expect(m.isSame(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'month mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day')).toBe(false, 'day mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day')).toBe(true, 'exact start of day') expect(m.isSame(dayjs(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day')).toBe(true, 'exact end of day') expect(m.isSame(dayjs(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day')).toBe(false, 'start of next day') expect(m.isSame(dayjs(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day')).toBe(false, 'end of previous day') expect(m.isSame(m, 'day')).toBe(true, 'same moments are in the same day') expect(+m).toEqual(+mCopy, 'isSame day should not change moment') }) test('is same hour', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'hour match') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'month mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour')).toBe(false, 'day mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour')).toBe(false, 'hour mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour')).toBe(true, 'exact start of hour') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour')).toBe(true, 'exact end of hour') expect(m.isSame(dayjs(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour')).toBe(false, 'start of next hour') expect(m.isSame(dayjs(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour')).toBe(false, 'end of previous hour') expect(m.isSame(m, 'hour')).toBe(true, 'same moments are in the same hour') expect(+m).toEqual(+mCopy, 'isSame hour should not change moment') }) test('is same minute', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'minute match') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'month mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute')).toBe(false, 'day mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute')).toBe(false, 'hour mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute')).toBe(false, 'minute mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute')).toBe(true, 'exact start of minute') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute')).toBe(true, 'exact end of minute') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute')).toBe(false, 'start of next minute') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute')).toBe(false, 'end of previous minute') expect(m.isSame(m, 'minute')).toBe(true, 'same moments are in the same minute') expect(+m).toEqual(+mCopy, 'isSame minute should not change moment') }) test('is same second', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'second match') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'year mismatch') expect(m.isSame(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'month mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second')).toBe(false, 'day mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second')).toBe(false, 'hour mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second')).toBe(false, 'minute mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second')).toBe(false, 'second mismatch') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second')).toBe(true, 'exact start of second') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second')).toBe(true, 'exact end of second') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second')).toBe(false, 'start of next second') expect(m.isSame(dayjs(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second')).toBe(false, 'end of previous second') expect(m.isSame(m, 'second')).toBe(true, 'same moments are in the same second') expect(+m).toEqual(+mCopy, 'isSame second should not change moment') }) test('is same millisecond', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'millisecond match') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds')).toBe(true, 'plural should work') expect(m.isSame(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is later') expect(m.isSame(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is earlier') expect(m.isSame(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is later') expect(m.isSame(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'day is later') expect(m.isSame(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond')).toBe(false, 'day is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond')).toBe(false, 'hour is later') expect(m.isSame(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond')).toBe(false, 'hour is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond')).toBe(false, 'minute is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond')).toBe(false, 'minute is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond')).toBe(false, 'second is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond')).toBe(false, 'second is earlier') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond')).toBe(false, 'millisecond is later') expect(m.isSame(dayjs(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond')).toBe(false, 'millisecond is earlier') expect(m.isSame(m, 'millisecond')).toBe(true, 'same moments are in the same millisecond') expect(+m).toEqual(+mCopy, 'isSame millisecond should not change moment') }) test('is same with invalid moments', () => { expect(dayjs(null).isSame(dayjs('2018-01-01'))).toBe(false, 'invalid moments are not considered equal') expect(dayjs('2018-01-01').isSame(dayjs(null))).toBe(false, 'invalid moments are not considered equal') }) // isAfter() test('is after year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year match') expect(m.isAfter(dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), 'years')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year')).toBe(false, 'exact start of year') expect(m.isAfter(dayjs(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'exact end of year') expect(m.isAfter(dayjs(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year')).toBe(false, 'start of next year') expect(m.isAfter(dayjs(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'end of previous year') expect(m.isAfter(dayjs(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'end of year far before') expect(m.isAfter(m, 'year')).toBe(false, 'same moments are not after the same year') expect(+m).toEqual(+mCopy, 'isAfter year should not change moment') }) test('is after month', () => { const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month match') expect(m.isAfter(dayjs(new Date(2010, 2, 6, 7, 8, 9, 10)), 'months')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month')).toBe(false, 'exact start of month') expect(m.isAfter(dayjs(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month')).toBe(false, 'exact end of month') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month')).toBe(false, 'start of next month') expect(m.isAfter(dayjs(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month')).toBe(true, 'end of previous month') expect(m.isAfter(dayjs(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month')).toBe(true, 'later month but earlier year') expect(m.isAfter(m, 'month')).toBe(false, 'same moments are not after the same month') expect(+m).toEqual(+mCopy, 'isAfter month should not change moment') }) test('is after day', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'day match') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 7, 8, 9, 10)), 'days')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day')).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day')).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day')).toBe(false, 'exact start of day') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day')).toBe(false, 'exact end of day') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day')).toBe(false, 'start of next day') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day')).toBe(true, 'end of previous day') expect(m.isAfter(dayjs(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day')).toBe(true, 'later day but earlier year') expect(m.isAfter(m, 'day')).toBe(false, 'same moments are not after the same day') expect(+m).toEqual(+mCopy, 'isAfter day should not change moment') }) test('is after hour', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'hour match') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hours')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour')).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour')).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour')).toBe(false, 'hour is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'hour is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour')).toBe(false, 'exact start of hour') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour')).toBe(false, 'exact end of hour') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour')).toBe(false, 'start of next hour') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour')).toBe(true, 'end of previous hour') expect(m.isAfter(m, 'hour')).toBe(false, 'same moments are not after the same hour') expect(+m).toEqual(+mCopy, 'isAfter hour should not change moment') }) test('is after minute', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'minute match') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minutes')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute')).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute')).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute')).toBe(false, 'hour is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute')).toBe(true, 'hour is earler') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute')).toBe(false, 'minute is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute')).toBe(true, 'minute is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute')).toBe(false, 'exact start of minute') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute')).toBe(false, 'exact end of minute') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute')).toBe(false, 'start of next minute') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute')).toBe(true, 'end of previous minute') expect(m.isAfter(m, 'minute')).toBe(false, 'same moments are not after the same minute') expect(+m).toEqual(+mCopy, 'isAfter minute should not change moment') }) test('is after second', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'second match') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'seconds')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second')).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second')).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second')).toBe(false, 'hour is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second')).toBe(true, 'hour is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second')).toBe(false, 'minute is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second')).toBe(true, 'minute is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second')).toBe(false, 'second is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second')).toBe(true, 'second is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second')).toBe(false, 'exact start of second') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second')).toBe(false, 'exact end of second') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second')).toBe(false, 'start of next second') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second')).toBe(true, 'end of previous second') expect(m.isAfter(m, 'second')).toBe(false, 'same moments are not after the same second') expect(+m).toEqual(+mCopy, 'isAfter second should not change moment') }) test('is after millisecond', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'millisecond match') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds')).toBe(true, 'plural should work') expect(m.isAfter(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond')).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond')).toBe(false, 'hour is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond')).toBe(true, 'hour is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond')).toBe(false, 'minute is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond')).toBe(true, 'minute is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond')).toBe(false, 'second is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond')).toBe(true, 'second is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond')).toBe(false, 'millisecond is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond')).toBe(true, 'millisecond is earlier') expect(m.isAfter(m, 'millisecond')).toBe(false, 'same moments are not after the same millisecond') expect(+m).toEqual(+mCopy, 'isAfter millisecond should not change moment') }) test('is after without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isAfter(dayjs(new Date(2012, 3, 2, 3, 5, 5, 10)))).toBe(false, 'year is later') expect(m.isAfter(dayjs(new Date(2010, 3, 2, 3, 3, 5, 10)))).toBe(true, 'year is earlier') expect(m.isAfter(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)))).toBe(false, 'month is later') expect(m.isAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)))).toBe(true, 'month is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)))).toBe(false, 'day is later') expect(m.isAfter(dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)))).toBe(true, 'day is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)))).toBe(false, 'hour is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)))).toBe(true, 'hour is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)))).toBe(false, 'minute is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)))).toBe(true, 'minute is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)))).toBe(false, 'second is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 11)))).toBe(true, 'second is earlier') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)))).toBe(false, 'millisecond match') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)))).toBe(false, 'millisecond is later') expect(m.isAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)))).toBe(true, 'millisecond is earlier') expect(m.isAfter(m)).toBe(false, 'moments are not after themselves') expect(+m).toEqual(+mCopy, 'isAfter second should not change moment') }) test('is after invalid', () => { const m = dayjs() const invalid = dayjs(null) expect(m.isAfter(invalid)).toBe(false, 'valid moment is not after invalid moment') expect(invalid.isAfter(m)).toBe(false, 'invalid moment is not after valid moment') expect(m.isAfter(invalid, 'year')).toBe(false, 'invalid moment year') expect(m.isAfter(invalid, 'month')).toBe(false, 'invalid moment month') expect(m.isAfter(invalid, 'day')).toBe(false, 'invalid moment day') expect(m.isAfter(invalid, 'hour')).toBe(false, 'invalid moment hour') expect(m.isAfter(invalid, 'minute')).toBe(false, 'invalid moment minute') expect(m.isAfter(invalid, 'second')).toBe(false, 'invalid moment second') expect(m.isAfter(invalid, 'milliseconds')).toBe(false, 'invalid moment milliseconds') }) // isBefore() test('is after without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 5, 5, 10)))).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 3, 5, 10)))).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)))).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)))).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)))).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)))).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)))).toBe(true, 'hour is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)))).toBe(false, 'hour is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)))).toBe(true, 'minute is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)))).toBe(false, 'minute is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)))).toBe(true, 'second is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 11)))).toBe(false, 'second is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)))).toBe(false, 'millisecond match') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)))).toBe(true, 'millisecond is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)))).toBe(false, 'millisecond is earlier') expect(m.isBefore(m)).toBe(false, 'moments are not before themselves') expect(+m).toEqual(+mCopy, 'isBefore second should not change moment') }) test('is before year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year match') expect(m.isBefore(dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year')).toBe(false, 'exact start of year') expect(m.isBefore(dayjs(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'exact end of year') expect(m.isBefore(dayjs(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year')).toBe(true, 'start of next year') expect(m.isBefore(dayjs(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'end of previous year') expect(m.isBefore(dayjs(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'end of year far before') expect(m.isBefore(m, 'year')).toBe(false, 'same moments are not before the same year') expect(+m).toEqual(+mCopy, 'isBefore year should not change moment') }) test('is before month', () => { const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month match') expect(m.isBefore(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'months')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month')).toBe(false, 'exact start of month') expect(m.isBefore(dayjs(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month')).toBe(false, 'exact end of month') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month')).toBe(true, 'start of next month') expect(m.isBefore(dayjs(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month')).toBe(false, 'end of previous month') expect(m.isBefore(dayjs(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month')).toBe(false, 'later month but earlier year') expect(m.isBefore(m, 'month')).toBe(false, 'same moments are not before the same month') expect(+m).toEqual(+mCopy, 'isBefore month should not change moment') }) test('is before day', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'day match') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 7, 8, 9, 10)), 'days')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day')).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day')).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day')).toBe(false, 'exact start of day') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day')).toBe(false, 'exact end of day') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day')).toBe(true, 'start of next day') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day')).toBe(false, 'end of previous day') expect(m.isBefore(dayjs(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day')).toBe(false, 'later day but earlier year') expect(m.isBefore(m, 'day')).toBe(false, 'same moments are not before the same day') expect(+m).toEqual(+mCopy, 'isBefore day should not change moment') }) test('is before hour', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'hour match') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hours')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour')).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour')).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour')).toBe(true, 'hour is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'hour is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour')).toBe(false, 'exact start of hour') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour')).toBe(false, 'exact end of hour') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour')).toBe(true, 'start of next hour') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour')).toBe(false, 'end of previous hour') expect(m.isBefore(m, 'hour')).toBe(false, 'same moments are not before the same hour') expect(+m).toEqual(+mCopy, 'isBefore hour should not change moment') }) test('is before minute', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'minute match') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minutes')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute')).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute')).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute')).toBe(true, 'hour is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute')).toBe(false, 'hour is earler') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute')).toBe(true, 'minute is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute')).toBe(false, 'minute is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute')).toBe(false, 'exact start of minute') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute')).toBe(false, 'exact end of minute') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute')).toBe(true, 'start of next minute') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute')).toBe(false, 'end of previous minute') expect(m.isBefore(m, 'minute')).toBe(false, 'same moments are not before the same minute') expect(+m).toEqual(+mCopy, 'isBefore minute should not change moment') }) test('is before second', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'second match') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'seconds')).toBe(true, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second')).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second')).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second')).toBe(true, 'hour is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second')).toBe(false, 'hour is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second')).toBe(true, 'minute is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second')).toBe(false, 'minute is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second')).toBe(true, 'second is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second')).toBe(false, 'second is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second')).toBe(false, 'exact start of second') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second')).toBe(false, 'exact end of second') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second')).toBe(true, 'start of next second') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second')).toBe(false, 'end of previous second') expect(m.isBefore(m, 'second')).toBe(false, 'same moments are not before the same second') expect(+m).toEqual(+mCopy, 'isBefore second should not change moment') }) test('is before millisecond', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'millisecond match') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds')).toBe(false, 'plural should work') expect(m.isBefore(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'year is later') expect(m.isBefore(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is earlier') expect(m.isBefore(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'month is later') expect(m.isBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'day is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond')).toBe(false, 'day is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond')).toBe(true, 'hour is later') expect(m.isBefore(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond')).toBe(false, 'hour is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond')).toBe(true, 'minute is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond')).toBe(false, 'minute is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond')).toBe(true, 'second is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond')).toBe(false, 'second is earlier') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond')).toBe(true, 'millisecond is later') expect(m.isBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond')).toBe(false, 'millisecond is earlier') expect(m.isBefore(m, 'millisecond')).toBe(false, 'same moments are not before the same millisecond') expect(+m).toEqual(+mCopy, 'isBefore millisecond should not change moment') }) test('is before invalid', () => { const m = dayjs() const invalid = dayjs(null) expect(m.isBefore(invalid)).toBe(false, 'valid moment is not before invalid moment') expect(invalid.isBefore(m)).toBe(false, 'invalid moment is not before valid moment') expect(m.isBefore(invalid, 'year')).toBe(false, 'invalid moment year') expect(m.isBefore(invalid, 'month')).toBe(false, 'invalid moment month') expect(m.isBefore(invalid, 'day')).toBe(false, 'invalid moment day') expect(m.isBefore(invalid, 'hour')).toBe(false, 'invalid moment hour') expect(m.isBefore(invalid, 'minute')).toBe(false, 'invalid moment minute') expect(m.isBefore(invalid, 'second')).toBe(false, 'invalid moment second') expect(m.isBefore(invalid, 'milliseconds')).toBe(false, 'invalid moment milliseconds') }) ================================================ FILE: test/constructor.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../src' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('supports instanceof dayjs', () => { expect(dayjs() instanceof dayjs).toBeTruthy() }) it('$isDayjsObject', () => { const mockOtherVersionDayjsObj = { $isDayjsObject: true } expect(dayjs.isDayjs(mockOtherVersionDayjsObj)).toBeTruthy() }) it('does not break isDayjs', () => { expect(dayjs.isDayjs(dayjs())).toBeTruthy() expect(dayjs.isDayjs(new Date())).toBeFalsy() }) ================================================ FILE: test/display.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../src' import th from '../src/locale/th' import '../src/locale/ja' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format no formatStr', () => { expect(dayjs().format()).toBe(moment().format()) }) it('Format invalid date', () => { expect(dayjs('').format()).toBe(new Date('').toString()) expect(dayjs('otherString').format()).toBe(new Date('otherString').toString()) }) it('Format Year YY YYYY', () => { expect(dayjs().format('YY')).toBe(moment().format('YY')) expect(dayjs().format('YYYY')).toBe(moment().format('YYYY')) expect(dayjs().format('Y')).toBe('Y') expect(dayjs().format('YYY')).toBe(`${moment().format('YY')}Y`) }) it('Format Month M MM MMM MMMM', () => { expect(dayjs().format('M')).toBe(moment().format('M')) expect(dayjs().format('MM')).toBe(moment().format('MM')) expect(dayjs().format('MMM')).toBe(moment().format('MMM')) expect(dayjs().format('MMMM')).toBe(moment().format('MMMM')) }) it('Format Day of Month D DD 1 - 31', () => { expect(dayjs().format('D')).toBe(moment().format('D')) expect(dayjs().format('DD')).toBe(moment().format('DD')) }) it('Format Day of Week d Sun - Sat', () => { expect(dayjs().format('d')).toBe(moment().format('d')) expect(dayjs().format('dd')).toBe(moment().format('dd')) expect(dayjs().format('ddd')).toBe(moment().format('ddd')) expect(dayjs().format('dddd')).toBe(moment().format('dddd')) }) it('Format Hour H HH 24-hour', () => { expect(dayjs().format('H')).toBe(moment().format('H')) expect(dayjs().format('HH')).toBe(moment().format('HH')) }) it('Format Hour h hh 12-hour', () => { const time = '2018-05-02T00:00:00.000' const expected = '12' expect(dayjs(time).format('h')).toBe(expected) expect(dayjs(time).format('h')).toBe(moment(time).format('h')) expect(dayjs(time).format('hh')).toBe(expected) expect(dayjs(time).format('hh')).toBe(moment(time).format('hh')) const time2 = '2018-05-02T01:00:00.000' expect(dayjs(time2).format('h')).toBe(moment(time2).format('h')) expect(dayjs(time2).format('h')).toBe('1') expect(dayjs(time2).format('hh')).toBe(moment(time2).format('hh')) expect(dayjs(time2).format('hh')).toBe('01') const time3 = '2018-05-02T23:00:00.000' const expected3 = '11' expect(dayjs(time3).format('h')).toBe(moment(time3).format('h')) expect(dayjs(time3).format('h')).toBe(expected3) expect(dayjs(time3).format('hh')).toBe(moment(time3).format('hh')) expect(dayjs(time3).format('hh')).toBe(expected3) }) it('Format meridiens a A am / pm', () => { const time = '2018-05-02T01:00:00.000' expect(dayjs(time).format('a')).toBe('am') expect(dayjs(time).format('a')).toBe(moment(time).format('a')) expect(dayjs(time).format('A')).toBe('AM') expect(dayjs(time).format('A')).toBe(moment(time).format('A')) expect(dayjs(time).locale('ja').format('a')).toBe('午前') expect(dayjs(time).locale('ja').format('a')) .toBe(moment(time).locale('ja').format('a')) const time2 = '2018-05-02T23:00:00.000' expect(dayjs(time2).format('a')).toBe('pm') expect(dayjs(time2).format('a')).toBe(moment(time2).format('a')) expect(dayjs(time2).format('A')).toBe('PM') expect(dayjs(time2).format('A')).toBe(moment(time2).format('A')) expect(dayjs(time2).locale('ja').format('a')).toBe('午後') expect(dayjs(time2).locale('ja').format('a')) .toBe(moment(time2).locale('ja').format('a')) }) it('Format Minute m mm', () => { expect(dayjs().format('m')).toBe(moment().format('m')) expect(dayjs().format('mm')).toBe(moment().format('mm')) }) it('Format Second s ss SSS', () => { expect(dayjs().format('s')).toBe(moment().format('s')) expect(dayjs().format('ss')).toBe(moment().format('ss')) expect(dayjs().format('SSS')).toBe(moment().format('SSS')) const date = '2011-11-05T14:48:01.002Z' expect(dayjs(date).format('s-ss-SSS')).toBe(moment(date).format('s-ss-SSS')) }) it('Format Time Zone ZZ', () => { MockDate.set(new Date('2018-05-02T23:00:00.000'), 60 * 8) expect(dayjs().format('Z')).toBe(moment().format('Z')) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) MockDate.set(new Date('2018-05-02T23:00:00.000'), 60 * 8 * -1) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) MockDate.set(new Date('2018-05-02T23:00:00.000'), 0) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) MockDate.set(new Date('2018-05-02T23:00:00.000'), 60 * 10) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) MockDate.set(new Date('2018-05-02T23:00:00.000'), 60 * 11 * -1) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) MockDate.set(new Date('2018-05-02T23:00:00.000'), 60 * 5.5 * -1) expect(dayjs().format('ZZ')).toBe(moment().format('ZZ')) }) it('Format ddd dd MMM with short locale', () => { expect(dayjs() .locale(th) .format('dd')).toBe(moment() .locale('th') .format('dd')) expect(dayjs() .locale(th) .format('ddd')).toBe(moment() .locale('th') .format('ddd')) expect(dayjs() .locale(th) .format('MMM')).toBe(moment() .locale('th') .format('MMM')) }) it('Format token value is 0', () => { const sundayDate = '2000-01-02' const sundayStr = 'd H m s' expect(dayjs(sundayDate).format(sundayStr)) .toBe(moment(sundayDate).format(sundayStr)) }) it('Format Complex with other string - : / ', () => { const string = 'YY-M-D / HH:mm:ss' expect(dayjs().format(string)).toBe(moment().format(string)) }) it('Format Escaping characters', () => { let string = '[Z] Z' expect(dayjs().format(string)).toBe(moment().format(string)) string = '[Z] Z [Z]' expect(dayjs().format(string)).toBe(moment().format(string)) }) describe('Difference', () => { it('empty -> default milliseconds', () => { const dateString = '20110101' const dayjsA = dayjs() const dayjsB = dayjs(dateString) const momentA = moment() const momentB = moment(dateString) expect(dayjsA.diff(dayjsB)).toBe(momentA.diff(momentB)) }) it('diff -> none dayjs object', () => { const dateString = '2013-02-08' const dayjsA = dayjs() const dayjsB = new Date(dateString) const momentA = moment() const momentB = new Date(dateString) expect(dayjsA.diff(dayjsB)).toBe(momentA.diff(momentB)) }) it('diff -> in seconds, minutes, hours, days, weeks, months, quarters, years ', () => { const dayjsA = dayjs() const dayjsB = dayjs().add(1000, 'days') const dayjsC = dayjs().subtract(1000, 'days') const momentA = moment() const momentB = moment().add(1000, 'days') const momentC = moment().subtract(1000, 'days') const units = ['seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'quarters', 'years'] units.forEach((unit) => { expect(dayjsA.diff(dayjsB, unit)).toBe(momentA.diff(momentB, unit)) expect(dayjsA.diff(dayjsB, unit, true)).toBe(momentA.diff(momentB, unit, true)) expect(dayjsA.diff(dayjsC, unit)).toBe(momentA.diff(momentC, unit)) expect(dayjsA.diff(dayjsC, unit, true)).toBe(momentA.diff(momentC, unit, true)) }) }) it('Special diff in month according to moment.js', () => { const dayjsA = dayjs('20160115') const dayjsB = dayjs('20160215') const dayjsC = dayjs('20170115') const momentA = moment('20160115') const momentB = moment('20160215') const momentC = moment('20170115') const units = ['months', 'quarters', 'years'] units.forEach((unit) => { expect(dayjsA.diff(dayjsB, unit)).toBe(momentA.diff(momentB, unit)) expect(dayjsA.diff(dayjsB, unit, true)).toBe(momentA.diff(momentB, unit, true)) expect(dayjsA.diff(dayjsC, unit)).toBe(momentA.diff(momentC, unit)) expect(dayjsA.diff(dayjsC, unit, true)).toBe(momentA.diff(momentC, unit, true)) }) }) it('MonthDiff', () => { expect(dayjs('2018-08-08').diff(dayjs('2018-08-08'), 'month')).toEqual(0) expect(dayjs('2018-09-08').diff(dayjs('2018-08-08'), 'month')).toEqual(1) expect(dayjs('2018-08-08').diff(dayjs('2018-09-08'), 'month')).toEqual(-1) expect(dayjs('2018-01-01').diff(dayjs('2018-01-01'), 'month')).toEqual(0) }) it('undefined edge case', () => { expect(dayjs().diff(undefined, 'seconds')).toBeDefined() }) }) it('Unix Timestamp (milliseconds)', () => { expect(dayjs().valueOf()).toBe(moment().valueOf()) }) it('Unix Timestamp (seconds)', () => { expect(dayjs().unix()).toBe(moment().unix()) }) it('Days in Month', () => { expect(dayjs().daysInMonth()).toBe(moment().daysInMonth()) expect(dayjs('20140201').daysInMonth()).toBe(moment('20140201').daysInMonth()) }) it('Utc Offset', () => { expect(dayjs('2013-01-01T00:00:00.000').utcOffset()).toBe(moment('2013-01-01T00:00:00.000').utcOffset()) expect(dayjs('2013-01-01T05:00:00.000').utcOffset()).toBe(moment('2013-01-01T05:00:00.000').utcOffset()) }) it('As Javascript Date -> toDate', () => { const base = dayjs() const momentBase = moment() const jsDate = base.toDate() expect(jsDate).toEqual(momentBase.toDate()) expect(jsDate).toEqual(new Date()) jsDate.setFullYear(1970) expect(jsDate.toUTCString()).not.toBe(base.toString()) }) it('As JSON -> toJSON', () => { expect(dayjs().toJSON()).toBe(moment().toJSON()) global.console.warn = jest.genMockFunction()// moment.js otherString will throw warn expect(dayjs('otherString').toJSON()).toBe(moment('otherString').toJSON()) expect(dayjs('otherString').toJSON()).toBe(null) }) it('As ISO 8601 String -> toISOString e.g. 2013-02-04T22:44:30.652Z', () => { expect(dayjs().toISOString()).toBe(moment().toISOString()) }) it('Year 1 formatted with YYYY should pad with zeroes', () => { const date = new Date(1, 0, 1) date.setUTCFullYear(1) // Required because 0-99 are parsed as 19xx in JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#year const res = dayjs(date).format('YYYY') expect(res.slice(0, 3)).toBe('000') // because of timezone, the result might be 0000 0001 or 0002 expect(res).toBe(moment(date).format('YYYY')) }) ================================================ FILE: test/get-set.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../src' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Year', () => { expect(dayjs().get('year')).toBe(moment().get('year')) expect(dayjs().year()).toBe(moment().year()) expect(dayjs().year(0).valueOf()).toBe(moment().year(0).valueOf()) expect(dayjs().year(2000).valueOf()).toBe(moment().year(2000).valueOf()) }) it('Month', () => { expect(dayjs().get('month')).toBe(moment().get('month')) expect(dayjs().month()).toBe(moment().month()) expect(dayjs().month(0).valueOf()).toBe(moment().month(0).valueOf()) expect(dayjs().month(1).valueOf()).toBe(moment().month(1).valueOf()) }) it('Day of Week', () => { expect(dayjs().get('day')).toBe(moment().get('day')) expect(dayjs().day()).toBe(moment().day()) expect(dayjs().day(0).format()).toBe(moment().day(0).format()) expect(dayjs().day(1).format()).toBe(moment().day(1).format()) }) it('Date', () => { expect(dayjs().get('date')).toBe(moment().get('date')) expect(dayjs().date()).toBe(moment().date()) expect(dayjs().date(0).valueOf()).toBe(moment().date(0).valueOf()) expect(dayjs().date(1).valueOf()).toBe(moment().date(1).valueOf()) }) it('Hour', () => { expect(dayjs().get('hour')).toBe(moment().get('hour')) expect(dayjs().hour()).toBe(moment().hour()) expect(dayjs().hour(0).valueOf()).toBe(moment().hour(0).valueOf()) expect(dayjs().hour(1).valueOf()).toBe(moment().hour(1).valueOf()) }) it('Minute', () => { expect(dayjs().get('minute')).toBe(moment().get('minute')) expect(dayjs().minute()).toBe(moment().minute()) expect(dayjs().minute(0).valueOf()).toBe(moment().minute(0).valueOf()) expect(dayjs().minute(1).valueOf()).toBe(moment().minute(1).valueOf()) }) it('Second', () => { expect(dayjs().get('second')).toBe(moment().get('second')) expect(dayjs().second()).toBe(moment().second()) expect(dayjs().second(0).valueOf()).toBe(moment().second(0).valueOf()) expect(dayjs().second(1).valueOf()).toBe(moment().second(1).valueOf()) }) it('Millisecond', () => { expect(dayjs().get('millisecond')).toBe(moment().get('millisecond')) expect(dayjs().millisecond()).toBe(moment().millisecond()) expect(dayjs().millisecond(0).valueOf()).toBe(moment().millisecond(0).valueOf()) expect(dayjs().millisecond(1).valueOf()).toBe(moment().millisecond(1).valueOf()) }) it('Set Day', () => { expect(dayjs().set('date', 30).valueOf()).toBe(moment().set('date', 30).valueOf()) }) it('Set Day of Week', () => { expect(dayjs().set('day', 0).valueOf()).toBe(moment().set('day', 0).valueOf()) }) it('Set Month', () => { expect(dayjs().set('month', 11).valueOf()).toBe(moment().set('month', 11).valueOf()) }) it('Set Year', () => { expect(dayjs().set('year', 2008).valueOf()).toBe(moment().set('year', 2008).valueOf()) }) it('Set Hour', () => { expect(dayjs().set('hour', 6).valueOf()).toBe(moment().set('hour', 6).valueOf()) }) it('Set Minute', () => { expect(dayjs().set('minute', 59).valueOf()).toBe(moment().set('minute', 59).valueOf()) }) it('Set Second', () => { expect(dayjs().set('second', 59).valueOf()).toBe(moment().set('second', 59).valueOf()) }) it('Set Millisecond', () => { expect(dayjs().set('millisecond', 999).valueOf()).toBe(moment().set('millisecond', 999).valueOf()) }) it('Set Month and Year in last day of month', () => { // 2011-07-31 -> 2011-02-28 const origin = dayjs('2011-07-31T14:48:00.000Z') const setMonth = origin.set('month', 1) expect(setMonth.month()).toBe(1) expect(origin.date()).toBe(31) expect(setMonth.date()).toBe(28) // 2000-02-29 -> 2001-02-28 const origin2 = dayjs('2000-02-29T14:48:00.000Z') const setYear = origin2.set('year', 2001) expect(setYear.month()).toBe(1) expect(origin2.date()).toBe(29) expect(setYear.date()).toBe(28) }) it('Set Unknown String', () => { const newDate = dayjs().set('Unknown String', 1) expect(newDate.valueOf()) .toBe(moment().set('Unknown String', 1).valueOf()) }) it('Immutable Set', () => { const dayjsA = dayjs() const dayjsB = dayjsA.set('year', 2011) const momentA = moment() const momentB = momentA.set('year', 2011) expect(dayjsA.valueOf()).not.toBe(dayjsB.valueOf()) expect(momentA.valueOf()).toBe(momentB.valueOf()) }) ================================================ FILE: test/issues/issue2027.correct-order.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import duration from '../../src/plugin/duration' import objectSupport from '../../src/plugin/objectSupport' dayjs.extend(objectSupport) dayjs.extend(duration) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) // issue 2027 describe('issue 2027 - order objectSupport > Duration', () => { it('add Duration object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const durationToAdd = dayjs.duration(6, 'hours') const testDate = baseDate.add(durationToAdd) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 20:01:02.003') }) it('subtract Duration object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const durationToAdd = dayjs.duration(6, 'hours') const testDate = baseDate.subtract(durationToAdd) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 08:01:02.003') }) it('add number with unit returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.add(6, 'hours') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 20:01:02.003') }) it('subtract number with unit returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.subtract(6, 'hours') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 08:01:02.003') }) it('parse string returns correct date', () => { const testDate = dayjs('2022-06-26T14:01:02.003') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 14:01:02.003') }) it('parse object returns correct date', () => { const testDate = dayjs({ year: '2022', month: '05', day: '26', hour: '14', minute: '01', second: '02', millisecond: '003' }) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 14:01:02.003') }) it('set hour with number returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.hour(10) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 10:01:02.003') }) it('set hour with object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.set({ hour: '10' }) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 10:01:02.003') }) }) ================================================ FILE: test/issues/issue2027.swapped-order.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import duration from '../../src/plugin/duration' import objectSupport from '../../src/plugin/objectSupport' dayjs.extend(duration) dayjs.extend(objectSupport) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) // issue 2027 describe('issue 2027 - order objectSupport > Duration', () => { it('add Duration object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const durationToAdd = dayjs.duration(6, 'hours') const testDate = baseDate.add(durationToAdd) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 20:01:02.003') }) it('subtract Duration object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const durationToAdd = dayjs.duration(6, 'hours') const testDate = baseDate.subtract(durationToAdd) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 08:01:02.003') }) it('add number with unit returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.add(6, 'hours') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 20:01:02.003') }) it('subtract number with unit returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.subtract(6, 'hours') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 08:01:02.003') }) it('parse string returns correct date', () => { const testDate = dayjs('2022-06-26T14:01:02.003') expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 14:01:02.003') }) it('parse object returns correct date', () => { const testDate = dayjs({ year: '2022', month: '05', day: '26', hour: '14', minute: '01', second: '02', millisecond: '003' }) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 14:01:02.003') }) it('set hour with number returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.hour(10) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 10:01:02.003') }) it('set hour with object returns correct date', () => { const baseDate = dayjs('2022-06-26T14:01:02.003') const testDate = baseDate.set({ hour: '10' }) expect(testDate.format('YYYY-MM-DD HH:mm:ss.SSS')).toBe('2022-06-26 10:01:02.003') }) }) ================================================ FILE: test/locale/ar-dz.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-dz' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-dz').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-dz').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-dz').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-dz').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-iq.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-iq' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-iq').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-iq').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-iq').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-iq').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-kw.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-kw' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-kw').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-kw').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-kw').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-kw').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-ly.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-ly' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-ly').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-ly').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-ly').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-ly').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-ma.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-ma' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-ma').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-ma').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-ma').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-ma').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-sa.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-sa' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-sa').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-sa').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-sa').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-sa').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar-tn.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' import locale from '../../src/locale/ar-tn' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { dayjs.locale(locale) expect(dayjs('2020-01-01 03:00:00').locale('ar-tn').format('A')).toEqual('ص') expect(dayjs('2020-01-01 11:00:00').locale('ar-tn').format('A')).toEqual('ص') expect(dayjs('2020-01-01 16:00:00').locale('ar-tn').format('A')).toEqual('م') expect(dayjs('2020-01-01 20:00:00').locale('ar-tn').format('A')).toEqual('م') }) ================================================ FILE: test/locale/ar.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import preParsePostFormat from '../../src/plugin/preParsePostFormat' import localeData from '../../src/plugin/localeData' import '../../src/locale/ar' dayjs.extend(localeData) dayjs.extend(relativeTime) dayjs.extend(preParsePostFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsAR = dayjs().locale('ar').add(i, 'day') const momentAR = moment().locale('ar').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsAR.format(testFormat1)).toEqual(momentAR.format(testFormat1)) expect(dayjsAR.format(testFormat2)).toEqual(momentAR.format(testFormat2)) expect(dayjsAR.format(testFormat3)).toEqual(momentAR.format(testFormat3)) } }) it('Preparse with locale function', () => { for (let i = 0; i <= 7; i += 1) { dayjs.locale('ar') const momentAR = moment().locale('ar').add(i, 'day') expect(dayjs(momentAR.format()).format()).toEqual(momentAR.format()) } }) it('RelativeTime: Time from X gets formatted', () => { const T = [ [44.4, 'second', 'منذ ثانية واحدة'] ] T.forEach((t) => { dayjs.locale('ar') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(t[2]) }) }) it('Format meridiem with locale function', () => { for (let i = 0; i <= 23; i += 1) { const hour = dayjs() .startOf('day') .add(i, 'hour') const meridiem = i > 12 ? 'م' : 'ص' expect(hour.locale('ar').format('A')).toBe(`${meridiem}`) } }) ================================================ FILE: test/locale/be.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import '../../src/locale/be' import relativeTime from '../../src/plugin/relativeTime' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Belarusian locale relative time in past and future with suffix', () => { const cases = [ [1, 's', 'праз некалькі секунд'], [-1, 's', 'некалькі секунд таму'], [1, 'm', 'праз хвіліну'], [-1, 'm', 'хвіліну таму'], [1, 'h', 'праз гадзіну'], [-1, 'h', 'гадзіну таму'], [1, 'd', 'праз дзень'], [-1, 'd', 'дзень таму'], [1, 'M', 'праз месяц'], [-1, 'M', 'месяц таму'], [2, 'd', 'праз 2 дні'], [-2, 'd', '2 дні таму'], [10, 'd', 'праз 10 дзён'], [-10, 'd', '10 дзён таму'], [6, 'm', 'праз 6 хвілін'], [-6, 'm', '6 хвілін таму'], [5, 'h', 'праз 5 гадзін'], [-5, 'h', '5 гадзін таму'], [3, 'M', 'праз 3 месяцы'], [-3, 'M', '3 месяцы таму'], [4, 'y', 'праз 4 гады'], [-4, 'y', '4 гады таму'] ] const locales = ['be'] locales.forEach((locale) => { cases.forEach((c) => { expect(dayjs() .add(c[0], c[1]) .locale(locale) .fromNow()).toBe(c[2]) expect(dayjs() .add(c[0], c[1]) .locale(locale) .fromNow()).toBe(moment() .add(c[0], c[1]) .locale(locale) .fromNow()) }) }) }) it('Belarusian locale relative time in past and future without suffix', () => { const cases = [ [1, 's', 'некалькі секунд'], [-1, 's', 'некалькі секунд'], [1, 'm', 'хвіліна'], [-1, 'm', 'хвіліна'], [1, 'h', 'гадзіна'], [-1, 'h', 'гадзіна'], // Test all plural forms for days [1, 'd', 'дзень'], [21, 'd', '21 дзень'], [31, 'd', 'месяц'], // 2-4 form [2, 'd', '2 дні'], [3, 'd', '3 дні'], [4, 'd', '4 дні'], // 5-20 and other cases [5, 'd', '5 дзён'], [6, 'd', '6 дзён'], // 11-14 special case [11, 'd', '11 дзён'], [12, 'd', '12 дзён'], [13, 'd', '13 дзён'], [14, 'd', '14 дзён'], // 22-24 [22, 'd', '22 дні'], [23, 'd', '23 дні'], [24, 'd', '24 дні'], // Test all plural forms for months [1, 'M', 'месяц'], [2, 'M', '2 месяцы'], [5, 'M', '5 месяцаў'], // Test all plural forms for years [1, 'y', 'год'], [2, 'y', '2 гады'], [5, 'y', '5 гадоў'], [11, 'y', '11 гадоў'], [21, 'y', '21 год'] ] const locales = ['be'] locales.forEach((locale) => { cases.forEach((c) => { expect(dayjs() .add(c[0], c[1]) .locale(locale) .fromNow(true)).toBe(c[2]) expect(dayjs() .add(c[0], c[1]) .locale(locale) .fromNow(true)).toBe(moment() .add(c[0], c[1]) .locale(locale) .fromNow(true)) }) }) }) it('Belarusian locale formats dates with correct month forms', () => { const tests = [ // Full month names { date: '2022-01-19', format: 'dd, D MMMM YYYY г.', expected: 'ср, 19 студзеня 2022 г.' }, { date: '2022-01-01', format: 'MMMM', expected: 'студзень' }, // Short month names in format form (with day) { date: '2022-01-15', format: 'D MMM', expected: '15 студ' }, { date: '2022-02-15', format: 'D MMM', expected: '15 лют' }, // Short month names in standalone form { date: '2022-01-01', format: 'MMM', expected: 'студ' }, { date: '2022-02-01', format: 'MMM', expected: 'лют' } ] tests.forEach(({ date, format, expected }) => { const dayjsWithLocale = dayjs(date).locale('be') expect(dayjsWithLocale.format(format)).toEqual(expected) }) }) ================================================ FILE: test/locale/bg.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import advancedFormat from '../../src/plugin/advancedFormat' import '../../src/locale/bg' dayjs.extend(relativeTime) dayjs.extend(advancedFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsBG = dayjs().locale('bg').add(i, 'day') const momentBG = moment().locale('bg').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsBG.format(testFormat1)).toEqual(momentBG.format(testFormat1)) expect(dayjsBG.format(testFormat2)).toEqual(momentBG.format(testFormat2)) expect(dayjsBG.format(testFormat3)).toEqual(momentBG.format(testFormat3)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [130, 'second'], // two minutes [43, 'minute'], // 44 minutes [1, 'hour'], // 1 hour [21, 'hour'], // 21 hours [2, 'day'], // 2 days [25, 'day'], // 25 days [2, 'month'], // 2 months [10, 'month'], // 10 months [18, 'month'], // 2 years [15, 'year'] // 15 years ] T.forEach((t) => { dayjs.locale('bg') moment.locale('bg') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) it('Ordinal', () => { dayjs.locale('bg') moment.locale('bg') for (let d = 1; d <= 31; d += 1) { const day = d < 10 ? `0${d}` : d const date = `2021-01-${day}` expect(dayjs(date).format('Do')).toBe(moment(date).format('Do')) } }) ================================================ FILE: test/locale/bn-bd.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import localeData from '../../src/plugin/localeData' import preParsePostFormat from '../../src/plugin/preParsePostFormat' import '../../src/locale/bn-bd' dayjs.extend(localeData) dayjs.extend(relativeTime) dayjs.extend(preParsePostFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsBN = dayjs() .locale('bn-bd') .add(i, 'day') const momentBN = moment() .locale('bn-bd') .add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsBN.format(testFormat1)).toEqual(momentBN.format(testFormat1)) expect(dayjsBN.format(testFormat2)).toEqual(momentBN.format(testFormat2)) expect(dayjsBN.format(testFormat3)).toEqual(momentBN.format(testFormat3)) } }) it('Month short', () => { const date = '2021-02-01T05:54:32.005Z' const dayjsBN = dayjs(date) .locale('bn-bd') const momentBN = moment(date) .locale('bn-bd') const testFormat1 = 'DD MMMM YYYY MMM' expect(dayjsBN.format(testFormat1)).toEqual(momentBN.format(testFormat1)) }) it('Preparse with locale function', () => { for (let i = 0; i <= 7; i += 1) { dayjs.locale('bn-bd') const momentBN = moment() .locale('bn-bd') .add(i, 'day') expect(dayjs(momentBN.format()).format()).toEqual(momentBN.format()) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [130, 'second'], // two minutes [43, 'minute'], // 44 minutes [1, 'hour'], // 1 hour [21, 'hour'], // 21 hours [2, 'day'], // 2 days [25, 'day'], // 25 days [2, 'month'], // 2 months [10, 'month'], // 10 months [18, 'month'], // 2 years [15, 'year'] // 15 years ] T.forEach((t) => { dayjs.locale('bn-bd') moment.locale('bn-bd') expect(dayjs().from(dayjs().add(t[0], t[1]))).toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) ================================================ FILE: test/locale/bn.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import localeData from '../../src/plugin/localeData' import preParsePostFormat from '../../src/plugin/preParsePostFormat' import '../../src/locale/bn' dayjs.extend(localeData) dayjs.extend(relativeTime) dayjs.extend(preParsePostFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsBN = dayjs() .locale('bn') .add(i, 'day') const momentBN = moment() .locale('bn') .add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsBN.format(testFormat1)).toEqual(momentBN.format(testFormat1)) expect(dayjsBN.format(testFormat2)).toEqual(momentBN.format(testFormat2)) expect(dayjsBN.format(testFormat3)).toEqual(momentBN.format(testFormat3)) } }) it('Month short', () => { const date = '2021-02-01T05:54:32.005Z' const dayjsBN = dayjs(date) .locale('bn') const momentBN = moment(date) .locale('bn') const testFormat1 = 'DD MMMM YYYY MMM' expect(dayjsBN.format(testFormat1)).toEqual(momentBN.format(testFormat1)) }) it('Preparse with locale function', () => { for (let i = 0; i <= 7; i += 1) { dayjs.locale('bn') const momentBN = moment() .locale('bn') .add(i, 'day') expect(dayjs(momentBN.format()).format()).toEqual(momentBN.format()) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [130, 'second'], // two minutes [43, 'minute'], // 44 minutes [1, 'hour'], // 1 hour [21, 'hour'], // 21 hours [2, 'day'], // 2 days [25, 'day'], // 25 days [2, 'month'], // 2 months [10, 'month'], // 10 months [18, 'month'], // 2 years [15, 'year'] // 15 years ] T.forEach((t) => { dayjs.locale('bn') moment.locale('bn') expect(dayjs().from(dayjs().add(t[0], t[1]))).toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) ================================================ FILE: test/locale/br.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/br' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsBR = dayjs().locale('br').add(i, 'day') const momentBR = moment().locale('br').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsBR.format(testFormat1)).toEqual(momentBR.format(testFormat1)) expect(dayjsBR.format(testFormat2)).toEqual(momentBR.format(testFormat2)) expect(dayjsBR.format(testFormat3)).toEqual(momentBR.format(testFormat3)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [130, 'second'], // two minutes [43, 'minute'], // 44 minutes [1, 'hour'], // 1 hour [21, 'hour'], // 21 hours [2, 'day'], // 2 days [25, 'day'], // 25 days [2, 'month'], // 2 months [10, 'month'], // 10 months [18, 'month'], // 2 years [15, 'year'] // 15 years ] T.forEach((t) => { dayjs.locale('br') moment.locale('br') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) ================================================ FILE: test/locale/cs.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/cs' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [43, 'minute'], // 43 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('cs') moment.locale('cs') const dayjsDay = dayjs() const momentDay = moment() const dayjsCompare = dayjs().add(t[0], t[1]) const momentCompare = moment().add(t[0], t[1]) expect(dayjsDay.from(dayjsCompare)) .toBe(momentDay.from(momentCompare)) expect(dayjsDay.to(dayjsCompare)) .toBe(momentDay.to(momentCompare)) expect(dayjsDay.from(dayjsCompare, true)) .toBe(momentDay.from(momentCompare, true)) }) }) ================================================ FILE: test/locale/de.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/de' import '../../src/locale/de-at' import '../../src/locale/de-ch' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('German locale relative time in past and future with suffix', () => { const cases = [ [1, 's', 'in ein paar Sekunden'], [-1, 's', 'vor ein paar Sekunden'], [1, 'm', 'in einer Minute'], [-1, 'm', 'vor einer Minute'], [1, 'h', 'in einer Stunde'], [-1, 'h', 'vor einer Stunde'], [1, 'd', 'in einem Tag'], [-1, 'd', 'vor einem Tag'], [1, 'M', 'in einem Monat'], [-1, 'M', 'vor einem Monat'], [2, 'd', 'in 2 Tagen'], [-2, 'd', 'vor 2 Tagen'], [10, 'd', 'in 10 Tagen'], [-10, 'd', 'vor 10 Tagen'], [6, 'm', 'in 6 Minuten'], [-6, 'm', 'vor 6 Minuten'], [5, 'h', 'in 5 Stunden'], [-5, 'h', 'vor 5 Stunden'], [3, 'M', 'in 3 Monaten'], [-3, 'M', 'vor 3 Monaten'], [4, 'y', 'in 4 Jahren'], [-4, 'y', 'vor 4 Jahren'] ] const locales = ['de', 'de-at', 'de-ch'] locales.forEach((locale) => { cases.forEach((c) => { expect(dayjs().add(c[0], c[1]).locale(locale).fromNow()) .toBe(c[2]) expect(dayjs().add(c[0], c[1]).locale(locale).fromNow()) .toBe(moment().add(c[0], c[1]).locale(locale).fromNow()) }) }) }) it('German locale relative time in past and future without suffix', () => { const cases = [ [1, 's', 'ein paar Sekunden'], [-1, 's', 'ein paar Sekunden'], [1, 'm', 'eine Minute'], [-1, 'm', 'eine Minute'], [1, 'h', 'eine Stunde'], [-1, 'h', 'eine Stunde'], [1, 'd', 'ein Tag'], [-1, 'd', 'ein Tag'], [2, 'd', '2 Tage'], [-2, 'd', '2 Tage'], [10, 'd', '10 Tage'], [-10, 'd', '10 Tage'], [6, 'm', '6 Minuten'], [-6, 'm', '6 Minuten'], [5, 'h', '5 Stunden'], [-5, 'h', '5 Stunden'], [3, 'M', '3 Monate'], [-3, 'M', '3 Monate'], [4, 'y', '4 Jahre'], [-4, 'y', '4 Jahre'] ] const locales = ['de', 'de-at', 'de-ch'] locales.forEach((locale) => { cases.forEach((c) => { expect(dayjs().add(c[0], c[1]).locale(locale).fromNow(true)) .toBe(c[2]) expect(dayjs().add(c[0], c[1]).locale(locale).fromNow(true)) .toBe(moment().add(c[0], c[1]).locale(locale).fromNow(true)) }) }) }) it('German locales use region specific names', () => { const locales = [ { locale: 'de', expectedFormattedDate: 'Mi., 19. Januar 2022' }, { locale: 'de-at', expectedFormattedDate: 'Mi., 19. Jänner 2022' }, { locale: 'de-ch', expectedFormattedDate: 'Mi, 19. Januar 2022' } ] locales.forEach((locale) => { const dayjsWithLocale = dayjs('2022-01-19').locale(locale.locale) expect(dayjsWithLocale.format('ddd, D. MMMM YYYY')).toEqual(locale.expectedFormattedDate) }) }) ================================================ FILE: test/locale/en.test.js ================================================ import dayjs from '../../src' import '../../src/locale/en' import '../../src/locale/en-gb' import '../../src/locale/en-in' import '../../src/locale/en-tt' import localizedFormat from '../../src/plugin/localizedFormat' dayjs.extend(localizedFormat) const locales = [ { locale: 'en', expectedDate: '12/25/2019' }, { locale: 'en-gb', expectedDate: '25/12/2019' }, { locale: 'en-in', expectedDate: '25/12/2019' }, { locale: 'en-tt', expectedDate: '25/12/2019' } ] describe('English date formats', () => { locales.forEach((locale) => { it(`should correctly format date with locale - ${locale.locale}`, () => { const dayjsWithLocale = dayjs('2019-12-25').locale(locale.locale) expect(dayjsWithLocale.format('L')).toEqual(locale.expectedDate) }) }) }) ================================================ FILE: test/locale/et.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/et' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [43, 'minute'], // 44 minutes [21, 'hour'], // 21 hours [25, 'day'], // 25 days [10, 'month'], // 2 month [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('et') moment.locale('et') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().subtract(t[0], t[1]))) .toBe(moment().from(moment().subtract(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) ================================================ FILE: test/locale/fi.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/fi' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Finnish locale relative time in past and future', () => { const cases = [ [1, 'd', 'päivän päästä'], [-1, 'd', 'päivä sitten'], [2, 'd', 'kahden päivän päästä'], [-2, 'd', 'kaksi päivää sitten'], [10, 'd', '10 päivän päästä'], [-10, 'd', '10 päivää sitten'], [6, 'm', 'kuuden minuutin päästä'], [-6, 'm', 'kuusi minuuttia sitten'], [5, 'h', 'viiden tunnin päästä'], [-5, 'h', 'viisi tuntia sitten'], [3, 'M', 'kolmen kuukauden päästä'], [-3, 'M', 'kolme kuukautta sitten'], [4, 'y', 'neljän vuoden päästä'], [-4, 'y', 'neljä vuotta sitten'] ] cases.forEach((c) => { expect(dayjs().add(c[0], c[1]).locale('fi').fromNow()) .toBe(c[2]) expect(dayjs().add(c[0], c[1]).locale('fi').fromNow()) .toBe(moment().add(c[0], c[1]).locale('fi').fromNow()) }) expect(dayjs().add(-10, 'd').locale('fi').fromNow(true)) .toBe('10 päivää') expect(dayjs().add(-10, 'd').locale('fi').fromNow(true)) .toBe(moment().add(-10, 'd').locale('fi').fromNow(true)) }) ================================================ FILE: test/locale/he.test.js ================================================ import moment from 'moment' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/he' dayjs.extend(relativeTime) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [43, 'minute'], // 43 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('he') moment.locale('he') const dayjsDay = dayjs() const momentDay = moment() const dayjsCompare = dayjs().add(t[0], t[1]) const momentCompare = moment().add(t[0], t[1]) expect(dayjsDay.from(dayjsCompare)).toBe(momentDay.from(momentCompare)) expect(dayjsDay.to(dayjsCompare)).toBe(momentDay.to(momentCompare)) expect(dayjsDay.from(dayjsCompare, true)).toBe(momentDay.from(momentCompare, true)) }) }) ================================================ FILE: test/locale/hr.test.js ================================================ import moment from 'moment' import dayjs from '../../src' import '../../src/locale/hr' it('Format month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsUK = dayjs().locale('hr').add(i, 'day') const momentUK = moment().locale('hr').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'dddd, MMMM D YYYY' const testFormat3 = 'MMMM' const testFormat4 = 'MMM' expect(dayjsUK.format(testFormat1)).toEqual(momentUK.format(testFormat1)) expect(dayjsUK.format(testFormat2)).toEqual(momentUK.format(testFormat2)) expect(dayjsUK.format(testFormat3)).toEqual(momentUK.format(testFormat3)) expect(dayjsUK.format(testFormat4)).toEqual(momentUK.format(testFormat4)) } }) ================================================ FILE: test/locale/hu.test.js ================================================ import moment from 'moment' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/hu' dayjs.extend(relativeTime) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [43, 'minute'], // 43 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('hu') moment.locale('hu') const dayjsDay = dayjs() const momentDay = moment() const dayjsCompare = dayjs().add(t[0], t[1]) const momentCompare = moment().add(t[0], t[1]) expect(dayjsDay.from(dayjsCompare)).toBe(momentDay.from(momentCompare)) expect(dayjsDay.to(dayjsCompare)).toBe(momentDay.to(momentCompare)) expect(dayjsDay.from(dayjsCompare, true)).toBe(momentDay.from(momentCompare, true)) }) }) ================================================ FILE: test/locale/is.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import '../../src/locale/is' import relativeTime from '../../src/plugin/relativeTime' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const expectations = [ [1, 's', 'nokkrar sekúndur', 'fyrir nokkrum sekúndum síðan', 'eftir nokkrar sekúndur'], [1, 'm', 'mínúta', 'fyrir mínútu síðan', 'eftir mínútu'], [1, 'h', 'klukkustund', 'fyrir klukkustund síðan', 'eftir klukkustund'], [1, 'd', 'dagur', 'fyrir degi síðan', 'eftir dag'], [1, 'M', 'mánuður', 'fyrir mánuði síðan', 'eftir mánuð'], [1, 'y', 'ár', 'fyrir ári síðan', 'eftir ár'], [2, 'm', '2 mínútur', 'fyrir 2 mínútum síðan', 'eftir 2 mínútur'], [2, 'h', '2 klukkustundir', 'fyrir 2 klukkustundum síðan', 'eftir 2 klukkustundir'], [2, 'd', '2 dagar', 'fyrir 2 dögum síðan', 'eftir 2 daga'], [2, 'M', '2 mánuðir', 'fyrir 2 mánuðum síðan', 'eftir 2 mánuði'], [2, 'y', '2 ár', 'fyrir 2 árum síðan', 'eftir 2 ár'], [21, 'm', '21 mínúta', 'fyrir 21 mínútu síðan', 'eftir 21 mínútu'], [21, 'h', '21 klukkustund', 'fyrir 21 klukkustund síðan', 'eftir 21 klukkustund'], [21, 'd', '21 dagur', 'fyrir 21 degi síðan', 'eftir 21 dag'], [21, 'y', '21 ár', 'fyrir 21 ári síðan', 'eftir 21 ár'] ] describe('moment compatibility', () => { it('without suffix', () => { expectations.forEach((expectation) => { const [offset, unit, expectationWithoutSuffix] = expectation const momentResult = moment() .add(offset, unit) .locale('is') .fromNow(true) expect(expectationWithoutSuffix).toBe(momentResult) }) }) it('past', () => { expectations.forEach((expectation) => { const [offset, unit, , pastExpectation] = expectation const momentResult = moment() .add(-offset, unit) .locale('is') .fromNow() expect(pastExpectation).toBe(momentResult) }) }) it('future', () => { expectations.forEach((expectation) => { const [offset, unit, , , futureExpectation] = expectation const momentResult = moment() .add(offset, unit) .locale('is') .fromNow() expect(futureExpectation).toBe(momentResult) }) }) }) describe('Icelandic output matches moment output', () => { it('without suffix', () => { expectations.forEach((expectation) => { const [offset, unit, expectationWithoutSuffix] = expectation const result = dayjs() .add(offset, unit) .locale('is') .fromNow(true) expect(result).toBe(expectationWithoutSuffix) }) }) it('past', () => { expectations.forEach((expectation) => { const [offset, unit, , pastExpectation] = expectation const result = dayjs() .add(-offset, unit) .locale('is') .fromNow() expect(result).toBe(pastExpectation) }) }) it('future', () => { expectations.forEach((expectation) => { const [offset, unit, , , futureExpectation] = expectation const result = dayjs() .add(offset, unit) .locale('is') .fromNow() expect(result).toBe(futureExpectation) }) }) }) ================================================ FILE: test/locale/it-ch.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import '../../src/locale/it-ch' import relativeTime from '../../src/plugin/relativeTime' import localizedFormat from '../../src/plugin/localizedFormat' dayjs.extend(relativeTime) dayjs.extend(localizedFormat) describe('Italian formats in Switzerland', () => { beforeEach(() => { dayjs.locale('it-ch') moment.locale('it-ch') MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsWithLocale = dayjs().add(i, 'day') const momentWithLocale = moment().add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'dddd, MMMM D YYYY' const testFormat3 = 'MMMM' const testFormat4 = 'MMM' const testFormat5 = 'L' expect(dayjsWithLocale.format(testFormat1)).toEqual(momentWithLocale.format(testFormat1)) expect(dayjsWithLocale.format(testFormat2)).toEqual(momentWithLocale.format(testFormat2)) expect(dayjsWithLocale.format(testFormat3)).toEqual(momentWithLocale.format(testFormat3)) expect(dayjsWithLocale.format(testFormat4)).toEqual(momentWithLocale.format(testFormat4)) expect(dayjsWithLocale.format(testFormat5)).toEqual(momentWithLocale.format(testFormat5)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [5, 'minute'], // 5 minutes [43, 'minute'], // 44 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) }) ================================================ FILE: test/locale/it.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import '../../src/locale/it' import relativeTime from '../../src/plugin/relativeTime' import localizedFormat from '../../src/plugin/localizedFormat' dayjs.extend(relativeTime) dayjs.extend(localizedFormat) describe('Italian formats', () => { beforeEach(() => { dayjs.locale('it') moment.locale('it') MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsWithLocale = dayjs().add(i, 'day') const momentWithLocale = moment().add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'dddd, MMMM D YYYY' const testFormat3 = 'MMMM' const testFormat4 = 'MMM' const testFormat5 = 'L' expect(dayjsWithLocale.format(testFormat1)).toEqual(momentWithLocale.format(testFormat1)) expect(dayjsWithLocale.format(testFormat2)).toEqual(momentWithLocale.format(testFormat2)) expect(dayjsWithLocale.format(testFormat3)).toEqual(momentWithLocale.format(testFormat3)) expect(dayjsWithLocale.format(testFormat4)).toEqual(momentWithLocale.format(testFormat4)) expect(dayjsWithLocale.format(testFormat5)).toEqual(momentWithLocale.format(testFormat5)) } }) it('RelativeTime: Time from X', () => { const T = [ [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [5, 'minute'], // 5 minutes [43, 'minute'], // 44 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) // moment.js uses `alcuni secondi` while dayjs uses `qualche secondo`. it('RelativeTime: A few seconds', () => { const T = [ [44.4, 'second'] // a few seconds ] T.forEach((t) => { expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe('qualche secondo fa') expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe('qualche secondo') }) }) }) ================================================ FILE: test/locale/ja.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ja' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Finnish locale relative time in past and future', () => { const cases = [ [1, 'd', '1日後'], [-1, 'd', '1日前'], [2, 'd', '2日後'], [-2, 'd', '2日前'], [10, 'd', '10日後'], [-10, 'd', '10日前'], [6, 'm', '6分後'], [-6, 'm', '6分前'], [5, 'h', '5時間後'], [-5, 'h', '5時間前'], [3, 'M', '3ヶ月後'], [-3, 'M', '3ヶ月前'], [4, 'y', '4年後'], [-4, 'y', '4年前'] ] cases.forEach((c) => { expect(dayjs().add(c[0], c[1]).locale('ja').fromNow()) .toBe(c[2]) expect(dayjs().add(c[0], c[1]).locale('ja').fromNow()) .toBe(moment().add(c[0], c[1]).locale('ja').fromNow()) }) expect(dayjs().add(-10, 'd').locale('ja').fromNow(true)) .toBe('10日') expect(dayjs().add(-10, 'd').locale('ja').fromNow(true)) .toBe(moment().add(-10, 'd').locale('ja').fromNow(true)) }) ================================================ FILE: test/locale/keys.test.js ================================================ import fs from 'fs' import path from 'path' import dayjs from '../../src' const localeDir = '../../src/locale' const Locale = [] const localeNameRegex = /\/\/ (.*) \[/ // load all locales from locale dir fs.readdirSync(path.join(__dirname, localeDir)) .forEach((file) => { const fPath = path.join(__dirname, localeDir, file) Locale.push({ name: file, // eslint-disable-next-line import/no-dynamic-require, global-require content: require(fPath).default, file: fs.readFileSync(fPath, 'utf-8') }) }) Locale.forEach((locale) => { it(`Locale keys for ${locale.content.name}`, () => { const { name, ordinal, weekdays, months, formats, relativeTime, weekdaysShort, monthsShort, weekdaysMin, weekStart, yearStart, meridiem } = locale.content // comments required const commentsMatchResult = locale.file.match(localeNameRegex) expect(commentsMatchResult[1]).not.toBeUndefined() expect(name).toEqual(locale.name.replace('.js', '')) expect(name).toBe(name.toLowerCase()) expect(weekdays).toEqual(expect.any(Array)) if (weekdaysShort) expect(weekdaysShort).toEqual(expect.any(Array)) if (weekdaysMin) expect(weekdaysMin).toEqual(expect.any(Array)) if (weekStart) expect(weekStart).toEqual(expect.any(Number)) if (yearStart) expect(yearStart).toEqual(expect.any(Number)) // months could be a function or array if (Array.isArray(months)) { expect(months).toEqual(expect.any(Array)) } else { expect(months(dayjs(), 'str')).toEqual(expect.any(String)) expect(months.f).toEqual(expect.any(Array)) expect(months.s).toEqual(expect.any(Array)) } // monthsShort could be a function or array if (monthsShort) { if (Array.isArray(monthsShort)) { expect(monthsShort).toEqual(expect.any(Array)) } else { expect(monthsShort(dayjs(), 'str')).toEqual(expect.any(String)) expect(monthsShort.f).toEqual(expect.any(Array)) expect(monthsShort.s).toEqual(expect.any(Array)) } } // function pass date return string or number or null if (name !== 'en') { // en ordinal set in advancedFormat for (let i = 1; i <= 31; i += 1) { expect(ordinal(i)).toEqual(expect.anything()) } } expect(dayjs().locale(name).$locale().name).toBe(name) if (formats) { const { LT, LTS, L, LL, LLL, LLLL, l, ll, lll, llll, ...remainingFormats } = formats expect(formats).toEqual(expect.objectContaining({ L: expect.any(String), LL: expect.any(String), LLL: expect.any(String), LLLL: expect.any(String), LT: expect.any(String), LTS: expect.any(String) })) expect(Object.keys(remainingFormats).length).toEqual(0) if (l) expect(l).toEqual(expect.any(String)) if (ll) expect(ll).toEqual(expect.any(String)) if (lll) expect(lll).toEqual(expect.any(String)) if (llll) expect(llll).toEqual(expect.any(String)) } if (relativeTime) { expect(Object.keys(relativeTime).sort()).toEqual(['d', 'dd', 'future', 'h', 'hh', 'm', 'mm', 'M', 'MM', 'past', 's', 'y', 'yy'] .sort()) } if (meridiem) { for (let i = 1; i <= 23; i += 1) { expect(meridiem(i)).toEqual(expect.anything()) } } }) }) ================================================ FILE: test/locale/ku.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import locale, { englishToArabicNumbersMap } from '../../src/locale/ku' import preParsePostFormat from '../../src/plugin/preParsePostFormat' dayjs.extend(preParsePostFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format meridiem correctly', () => { for (let i = 0; i <= 23; i += 1) { const dayjsKu = dayjs() .startOf('day') .add(i, 'hour') const hour = (i % 12 || 12) .toString() .replace(/\d/g, match => englishToArabicNumbersMap[match]) const m = i < 12 ? 'پ.ن' : 'د.ن' expect(dayjsKu.locale('ku').format('h A')).toBe(`${hour} ${m}`) } }) it('Preparse with locale function', () => { for (let i = 0; i <= 7; i += 1) { dayjs.locale(locale) const momentKu = moment() .locale('ku') .add(i, 'day') expect(dayjs(momentKu.format()).format()).toEqual(momentKu.format()) } }) ================================================ FILE: test/locale/lt.test.js ================================================ import moment from 'moment' import dayjs from '../../src' import '../../src/locale/lt' it('Format month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsUK = dayjs().locale('lt').add(i, 'day') const momentUK = moment().locale('lt').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'dddd, MMMM D YYYY' const testFormat3 = 'MMMM' const testFormat4 = 'MMM' expect(dayjsUK.format(testFormat1)).toEqual(momentUK.format(testFormat1)) expect(dayjsUK.format(testFormat2)).toEqual(momentUK.format(testFormat2)) expect(dayjsUK.format(testFormat3)).toEqual(momentUK.format(testFormat3)) expect(dayjsUK.format(testFormat4)).toEqual(momentUK.format(testFormat4)) } }) ================================================ FILE: test/locale/pl.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/pl' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsUK = dayjs().locale('pl').add(i, 'day') const momentUK = moment().locale('pl').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'dddd, MMMM D YYYY' const testFormat3 = 'MMMM' const testFormat4 = 'MMM' expect(dayjsUK.format(testFormat1)).toEqual(momentUK.format(testFormat1)) expect(dayjsUK.format(testFormat2)).toEqual(momentUK.format(testFormat2)) expect(dayjsUK.format(testFormat3)).toEqual(momentUK.format(testFormat3)) expect(dayjsUK.format(testFormat4)).toEqual(momentUK.format(testFormat4)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [5, 'minute'], // 5 minutes [43, 'minute'], // 44 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('pl') moment.locale('pl') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) ================================================ FILE: test/locale/ru.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/ru' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsRU = dayjs().locale('ru').add(i, 'day') const momentRU = moment().locale('ru').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsRU.format(testFormat1)).toEqual(momentRU.format(testFormat1)) expect(dayjsRU.format(testFormat2)).toEqual(momentRU.format(testFormat2)) expect(dayjsRU.format(testFormat3)).toEqual(momentRU.format(testFormat3)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [43, 'minute'], // 44 minutes [21, 'hour'], // 21 hours [25, 'day'], // 25 days [10, 'month'], // 2 month [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('ru') moment.locale('ru') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) it('Meridiem', () => { expect(dayjs('2020-01-01 03:00:00').locale('ru').format('A')).toEqual('ночи') expect(dayjs('2020-01-01 11:00:00').locale('ru').format('A')).toEqual('утра') expect(dayjs('2020-01-01 16:00:00').locale('ru').format('A')).toEqual('дня') expect(dayjs('2020-01-01 20:00:00').locale('ru').format('A')).toEqual('вечера') }) ================================================ FILE: test/locale/sk.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/sk' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [2, 'minute'], // 2 minutes [43, 'minute'], // 43 minutes [45, 'minute'], // an hour [3, 'hour'], // 3 hours [21, 'hour'], // 21 hours [1, 'day'], // a day [3, 'day'], // 3 day [25, 'day'], // 25 days [1, 'month'], // a month [2, 'month'], // 2 month [10, 'month'], // 10 month [1, 'year'], // a year [2, 'year'], // 2 year [5, 'year'], // 5 year [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('sk') moment.locale('sk') const dayjsDay = dayjs() const momentDay = moment() const dayjsCompare = dayjs().add(t[0], t[1]) const momentCompare = moment().add(t[0], t[1]) expect(dayjsDay.from(dayjsCompare)) .toBe(momentDay.from(momentCompare)) expect(dayjsDay.to(dayjsCompare)) .toBe(momentDay.to(momentCompare)) expect(dayjsDay.from(dayjsCompare, true)) .toBe(momentDay.from(momentCompare, true)) }) }) ================================================ FILE: test/locale/sl.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/sl' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Slovenian locale relative time in past and future', () => { const cases = [ [1, 's', 'čez nekaj sekund', 'nekaj sekund'], [-1, 's', 'pred nekaj sekundami', 'nekaj sekund'], [1, 'm', 'čez eno minuto', 'ena minuta'], [-1, 'm', 'pred eno minuto', 'ena minuta'], [2, 'm', 'čez 2 minuti', '2 minuti'], [-2, 'm', 'pred 2 minutama', '2 minuti'], [3, 'm', 'čez 3 minute', '3 minute'], [-3, 'm', 'pred 3 minutami', '3 minute'], [5, 'm', 'čez 5 minut', '5 minut'], [-5, 'm', 'pred 5 minutami', '5 minut'], [1, 'h', 'čez eno uro', 'ena ura'], [-1, 'h', 'pred eno uro', 'ena ura'], [2, 'h', 'čez 2 uri', '2 uri'], [-2, 'h', 'pred 2 urama', '2 uri'], [3, 'h', 'čez 3 ure', '3 ure'], [-3, 'h', 'pred 3 urami', '3 ure'], [5, 'h', 'čez 5 ur', '5 ur'], [-5, 'h', 'pred 5 urami', '5 ur'], [1, 'd', 'čez en dan', 'en dan'], [-1, 'd', 'pred enim dnem', 'en dan'], [2, 'd', 'čez 2 dneva', '2 dneva'], [-2, 'd', 'pred 2 dnevoma', '2 dneva'], [3, 'd', 'čez 3 dni', '3 dni'], [-3, 'd', 'pred 3 dnevi', '3 dni'], [5, 'd', 'čez 5 dni', '5 dni'], [-5, 'd', 'pred 5 dnevi', '5 dni'], [1, 'M', 'čez en mesec', 'en mesec'], [-1, 'M', 'pred enim mesecem', 'en mesec'], [2, 'M', 'čez 2 meseca', '2 meseca'], [-2, 'M', 'pred 2 mesecema', '2 meseca'], [3, 'M', 'čez 3 mesece', '3 mesece'], [-3, 'M', 'pred 3 meseci', '3 mesece'], [5, 'M', 'čez 5 mesecev', '5 mesecev'], [-5, 'M', 'pred 5 meseci', '5 mesecev'], [1, 'y', 'čez eno leto', 'eno leto'], [-1, 'y', 'pred enim letom', 'eno leto'], [2, 'y', 'čez 2 leti', '2 leti'], [-2, 'y', 'pred 2 letoma', '2 leti'], [3, 'y', 'čez 3 leta', '3 leta'], [-3, 'y', 'pred 3 leti', '3 leta'], [5, 'y', 'čez 5 let', '5 let'], [-5, 'y', 'pred 5 leti', '5 let'] // these are rounded // if user decides to change rounding then it would be good to test them also // [102, 's', 'čez 102 sekundi', '102 sekundi'], // [-102, 's', 'pred 102 sekundama', '102 sekundi'], // [103, 's', 'čez 103 sekunde', '103 sekunde'], // [-103, 's', 'pred 103 sekundami', '103 sekunde'], // [114, 's', 'čez 114 sekund', '114 sekund'], // [-114, 's', 'pred 114 sekundami', '114 sekund'], // [-102, 'm', 'čez 102 minuti', '102 minuti'], // [-102, 'm', 'pred 102 minutama', '102 minuti'], // [103, 'm', 'čez 103 minute', '103 minute'], // [-103, 'm', 'pred 103 minutami', '103 minute'], // [114, 'm', 'čez 114 minut', '114 minut'], // [-114, 'm', 'pred 114 minutami', '114 minut'] ] cases.forEach((c) => { // With suffix expect(dayjs().add(c[0], c[1]).locale('sl').fromNow()).toBe(c[2]) // Without suffix expect(dayjs().add(c[0], c[1]).locale('sl').fromNow(true)).toBe(c[3]) }) }) ================================================ FILE: test/locale/sr-cyrl.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/sr-cyrl' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Serbian cyrillic locale relative time in past and future', () => { const cases = [ [1, 's', 'за неколико секунди', 'неколико секунди'], [-1, 's', 'пре неколико секунди', 'неколико секунди'], [4, 's', 'за неколико секунди', 'неколико секунди'], [1, 'm', 'за један минут', 'један минут'], [-1, 'm', 'пре једног минута', 'један минут'], [4, 'm', 'за 4 минута', '4 минута'], [5, 'm', 'за 5 минута', '5 минута'], [21, 'm', 'за 21 минут', '21 минут'], [1, 'h', 'за један сат', 'један сат'], [-1, 'h', 'пре једног сата', 'један сат'], [4, 'h', 'за 4 сата', '4 сата'], [5, 'h', 'за 5 сати', '5 сати'], [21, 'h', 'за 21 сат', '21 сат'], [1, 'd', 'за један дан', 'један дан'], [-1, 'd', 'пре једног дана', 'један дан'], [4, 'd', 'за 4 дана', '4 дана'], [5, 'd', 'за 5 дана', '5 дана'], [21, 'd', 'за 21 дан', '21 дан'], [1, 'M', 'за један месец', 'један месец'], [-1, 'M', 'пре једног месеца', 'један месец'], [4, 'M', 'за 4 месеца', '4 месеца'], [5, 'M', 'за 5 месеци', '5 месеци'], [10, 'M', 'за 10 месеци', '10 месеци'], [1, 'y', 'за једну годину', 'једна година'], [-1, 'y', 'пре једне године', 'једна година'], [4, 'y', 'за 4 године', '4 године'], [5, 'y', 'за 5 година', '5 година'], [21, 'y', 'за 21 годину', '21 година'] ] cases.forEach((c) => { expect(dayjs().add(c[0], c[1]).locale('sr-cyrl').fromNow()).toBe(c[2]) expect(dayjs().add(c[0], c[1]).locale('sr-cyrl').fromNow(true)).toBe(c[3]) // TODO: compare to momentjs once logic and grammar are fixed there }) }) ================================================ FILE: test/locale/sr.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/sr' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Serbian locale relative time in past and future', () => { const cases = [ [1, 's', 'za nekoliko sekundi', 'nekoliko sekundi'], [-1, 's', 'pre nekoliko sekundi', 'nekoliko sekundi'], [4, 's', 'za nekoliko sekundi', 'nekoliko sekundi'], [1, 'm', 'za jedan minut', 'jedan minut'], [-1, 'm', 'pre jednog minuta', 'jedan minut'], [4, 'm', 'za 4 minuta', '4 minuta'], [5, 'm', 'za 5 minuta', '5 minuta'], [21, 'm', 'za 21 minut', '21 minut'], [1, 'h', 'za jedan sat', 'jedan sat'], [-1, 'h', 'pre jednog sata', 'jedan sat'], [4, 'h', 'za 4 sata', '4 sata'], [5, 'h', 'za 5 sati', '5 sati'], [21, 'h', 'za 21 sat', '21 sat'], [1, 'd', 'za jedan dan', 'jedan dan'], [-1, 'd', 'pre jednog dana', 'jedan dan'], [4, 'd', 'za 4 dana', '4 dana'], [5, 'd', 'za 5 dana', '5 dana'], [21, 'd', 'za 21 dan', '21 dan'], [1, 'M', 'za jedan mesec', 'jedan mesec'], [-1, 'M', 'pre jednog meseca', 'jedan mesec'], [4, 'M', 'za 4 meseca', '4 meseca'], [5, 'M', 'za 5 meseci', '5 meseci'], [10, 'M', 'za 10 meseci', '10 meseci'], [1, 'y', 'za jednu godinu', 'jedna godina'], [-1, 'y', 'pre jedne godine', 'jedna godina'], [4, 'y', 'za 4 godine', '4 godine'], [5, 'y', 'za 5 godina', '5 godina'], [21, 'y', 'za 21 godinu', '21 godina'] ] cases.forEach((c) => { // With suffix expect(dayjs().add(c[0], c[1]).locale('sr').fromNow()).toBe(c[2]) // Without suffix expect(dayjs().add(c[0], c[1]).locale('sr').fromNow(true)).toBe(c[3]) // TODO: compare to momentjs once logic and grammar are fixed there }) }) ================================================ FILE: test/locale/sv-fi.test.js ================================================ import dayjs from '../../src' import localizedFormat from '../../src/plugin/localizedFormat' import '../../src/locale/sv-fi' dayjs.extend(localizedFormat) it('Finland Swedish locale', () => { // time expect(dayjs('2019-02-01 12:34:56').locale('sv-fi').format('LT')) .toBe('12.34') expect(dayjs('2019-02-01 23:45:56').locale('sv-fi').format('LTS')) .toBe('23.45.56') // date expect(dayjs('2019-02-01').locale('sv-fi').format('L')) .toBe('01.02.2019') expect(dayjs('2019-12-15').locale('sv-fi').format('LL')) .toBe('15. december 2019') // short expect(dayjs('2019-02-01').locale('sv-fi').format('l')) .toBe('1.2.2019') expect(dayjs('2019-12-15').locale('sv-fi').format('ll')) .toBe('15. dec 2019') // date and time expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('LLL')) .toBe('1. mars 2019, kl. 12.30') expect(dayjs('2021-06-12 17:30').locale('sv-fi').format('LLLL')) .toBe('lördag, 12. juni 2021, kl. 17.30') // short expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('lll')) .toBe('1. mar 2019, kl. 12.30') expect(dayjs('2021-06-01 17:30').locale('sv-fi').format('llll')) .toBe('tis, 1. jun 2021, kl. 17.30') }) ================================================ FILE: test/locale/sv.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import advancedFormat from '../../src/plugin/advancedFormat' import '../../src/locale/sv' dayjs.extend(advancedFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Swedish locale Do 1a not format to 1am', () => { expect(dayjs('2019-01-01').locale('sv').format('dddd Do MMMM')) .toBe('tisdag 1a januari') expect(dayjs('2019-01-02').locale('sv').format('dddd Do MMMM')) .toBe('onsdag 2a januari') }) ================================================ FILE: test/locale/uk.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/uk' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsUK = dayjs().locale('uk').add(i, 'day') const momentUK = moment().locale('uk').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsUK.format(testFormat1)).toEqual(momentUK.format(testFormat1)) expect(dayjsUK.format(testFormat2)).toEqual(momentUK.format(testFormat2)) expect(dayjsUK.format(testFormat3)).toEqual(momentUK.format(testFormat3)) } }) it('RelativeTime: Time from X', () => { const T = [ [44.4, 'second'], // a few seconds [89.5, 'second'], // a minute [43, 'minute'], // 44 minutes [21, 'hour'], // 21 hours [25, 'day'], // 25 days [10, 'month'], // 2 month [18, 'month'] // 2 years ] T.forEach((t) => { dayjs.locale('uk') moment.locale('uk') expect(dayjs().from(dayjs().add(t[0], t[1]))) .toBe(moment().from(moment().add(t[0], t[1]))) expect(dayjs().from(dayjs().add(t[0], t[1]), true)) .toBe(moment().from(moment().add(t[0], t[1]), true)) }) }) it('hour', () => { const str0 = '2020-03-18 19:15:00' const str = '2020-03-18 20:15:00' const result = dayjs(str0).locale('uk').to(str) expect(result).toEqual(moment(str0).locale('uk').to(str)) const result2 = dayjs(str).locale('uk').to(str0, true) expect(result2).toEqual('година') // different from moment.js }) ================================================ FILE: test/locale/zh-cn.test.js ================================================ // import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import '../../src/locale/zh-cn' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Meridiem', () => { // the '中午' is different to moment.js 11-13 expect(dayjs('2020-01-01 10:59:59').locale('zh-cn').format('A')).toEqual('上午') expect(dayjs('2020-01-01 11:00:00').locale('zh-cn').format('A')).toEqual('中午') expect(dayjs('2020-01-01 12:59:59').locale('zh-cn').format('A')).toEqual('中午') expect(dayjs('2020-01-01 13:00:00').locale('zh-cn').format('A')).toEqual('下午') }) ================================================ FILE: test/locale/zh-hk.test.js ================================================ import dayjs from '../../src' import advancedFormat from '../../src/plugin/advancedFormat' import weekOfYear from '../../src/plugin/weekOfYear' import '../../src/locale/zh' import '../../src/locale/zh-cn' import '../../src/locale/zh-hk' import '../../src/locale/zh-tw' dayjs.extend(advancedFormat).extend(weekOfYear) const zh = dayjs().locale('zh') const zhCN = dayjs().locale('zh-cn') const zhHK = dayjs().locale('zh-hk') const zhTW = dayjs().locale('zh-tw') test('ordinal', () => { expect(zh.format('wo')).toEqual(`${zh.format('w')}周`) expect(zhCN.format('wo')).toEqual(`${zhCN.format('w')}周`) expect(zhHK.format('wo')).toEqual(`${zhHK.format('w')}週`) expect(zhTW.format('wo')).toEqual(`${zhTW.format('w')}週`) }) test('Meridiem', () => { for (let i = 0; i <= 24; i += 1) { expect(zh.add(i, 'hour').format('A')).toBe(zhCN.add(i, 'hour').format('A')) } }) test('Meridiem', () => { expect(dayjs('2020-01-01 05:59:59').locale('zh-hk').format('A')).toEqual('凌晨') expect(dayjs('2020-01-01 08:59:59').locale('zh-hk').format('A')).toEqual('早上') expect(dayjs('2020-01-01 10:59:59').locale('zh-hk').format('A')).toEqual('上午') expect(dayjs('2020-01-01 11:00:00').locale('zh-hk').format('A')).toEqual('中午') expect(dayjs('2020-01-01 12:59:59').locale('zh-hk').format('A')).toEqual('中午') expect(dayjs('2020-01-01 13:00:00').locale('zh-hk').format('A')).toEqual('下午') }) ================================================ FILE: test/locale/zh-tw.test.js ================================================ import dayjs from '../../src' import advancedFormat from '../../src/plugin/advancedFormat' import weekOfYear from '../../src/plugin/weekOfYear' import '../../src/locale/zh' import '../../src/locale/zh-tw' dayjs.extend(advancedFormat).extend(weekOfYear) const zh = dayjs().locale('zh') const zhTW = dayjs().locale('zh-tw') test('ordinal', () => { expect(zh.format('wo')).toEqual(`${zh.format('w')}周`) expect(zhTW.format('wo')).toEqual(`${zhTW.format('w')}週`) }) test('Meridiem', () => { for (let i = 0; i <= 24; i += 1) { expect(zh.add(i, 'hour').format('A')).toBe(zhTW.add(i, 'hour').format('A')) } }) ================================================ FILE: test/locale/zh.test.js ================================================ import dayjs from '../../src' import advancedFormat from '../../src/plugin/advancedFormat' import weekOfYear from '../../src/plugin/weekOfYear' import '../../src/locale/zh' import '../../src/locale/zh-cn' dayjs.extend(advancedFormat).extend(weekOfYear) const zh = dayjs().locale('zh') const zhCN = dayjs().locale('zh-cn') test('ordinal', () => { expect(zh.format('wo')).toEqual(`${zh.format('w')}周`) }) test('Meridiem', () => { for (let i = 0; i <= 24; i += 1) { expect(zh.add(i, 'hour').format('A')).toBe(zhCN.add(i, 'hour').format('A')) } }) ================================================ FILE: test/locale.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../src' import es from '../src/locale/es' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const format = 'dddd D, MMMM' const NOT_SUPPORTED_LOCALE_STRING = 'not_supported_locale_string' it('Uses spanish locale through constructor', () => { // not recommend expect(dayjs('2018-4-28', { locale: es }) .format(format)) .toBe('sábado 28, abril') }) it('set locale for one instance only', () => { expect(dayjs('2018-4-28') .format(format)) .toBe('Saturday 28, April') expect(dayjs('2018-4-28') .locale(es).format(format)) .toBe('sábado 28, abril') expect(dayjs('2018-4-28') .format(format)) .toBe('Saturday 28, April') }) it('set global locale', () => { dayjs.locale('en') expect(dayjs('2018-4-28').format(format)) .toBe('Saturday 28, April') dayjs.locale(es) expect(dayjs('2018-4-28').format(format)) .toBe('sábado 28, abril') dayjs.locale('en') expect(dayjs('2018-4-28').format(format)) .toBe('Saturday 28, April') }) it('get instance locale name', () => { expect(dayjs().locale()).toBe('en') expect(dayjs().locale()).toBe(moment().locale()) expect(dayjs().locale('es').locale()).toBe('es') expect(dayjs().locale('es').locale()).toBe(moment().locale('es').locale()) dayjs.locale(es) moment.locale('es') expect(dayjs().locale()).toBe('es') expect(dayjs().locale()).toBe(moment().locale()) }) it('immutable instance locale', () => { dayjs.locale('en') const origin = dayjs('2018-4-28') expect(origin.format(format)) .toBe('Saturday 28, April') expect(origin.locale('es').format(format)) .toBe('sábado 28, abril') const changed = origin.locale('es') expect(changed.format(format)) .toBe('sábado 28, abril') expect(origin.format(format)) .toBe('Saturday 28, April') }) it('User custom locale', () => { expect(dayjs('2018-4-28') .locale('xx', { weekdays: Array(7).fill('week'), months: Array(12).fill('month') }) .format(format)) .toBe('week 28, month') }) describe('Instance locale inheritance', () => { const esDayjs = dayjs('2018-4-28').locale(es) it('Clone', () => { expect(esDayjs.clone().format(format)) .toBe('sábado 28, abril') expect(dayjs(esDayjs).format(format)) .toBe('sábado 28, abril') }) it('StartOf EndOf', () => { expect(esDayjs.startOf('year').format(format)) .toBe('lunes 1, enero') expect(esDayjs.endOf('day').format(format)) .toBe('sábado 28, abril') }) it('Set', () => { expect(esDayjs.set('year', 2017).format(format)) .toBe('viernes 28, abril') }) it('Add', () => { expect(esDayjs.add(1, 'year').format(format)) .toBe('domingo 28, abril') expect(esDayjs.add(1, 'month').format(format)) .toBe('lunes 28, mayo') expect(esDayjs.add(1, 'minute').format(format)) .toBe('sábado 28, abril') }) it('dayjs.locale() returns locale name', () => { dayjs.locale(es) moment.locale('es') expect(dayjs.locale()).toBe(moment.locale()) dayjs.locale('en') moment.locale('en') expect(dayjs.locale()).toBe(moment.locale()) }) }) it('Not supported locale string fallback to previous one (instance)', () => { const D = dayjs() expect(D.locale()).toBe('en') const D2 = D.locale(NOT_SUPPORTED_LOCALE_STRING) expect(D2.locale()).toBe('en') expect(D2.format()).toBe(D.format()) const D3 = D2.locale('es') expect(D3.locale()).toBe('es') const D4 = D3.locale(NOT_SUPPORTED_LOCALE_STRING) expect(D4.locale()).toBe('es') }) it('Not supported locale string fallback to previous one (global)', () => { expect(dayjs().locale()).toBe('en') dayjs.locale(NOT_SUPPORTED_LOCALE_STRING) expect(dayjs().locale()).toBe('en') dayjs.locale('es') expect(dayjs().locale()).toBe('es') dayjs.locale(NOT_SUPPORTED_LOCALE_STRING) expect(dayjs().locale()).toBe('es') }) ================================================ FILE: test/manipulate.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../src' import '../src/locale/zh-cn' import '../src/locale/ar' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('StartOf EndOf', () => { it('StartOf EndOf Year ... with s and upper case', () => { const testArr = ['Year', 'year', 'YearS', 'month', 'day', 'date', 'week', 'hour', 'minute', 'second'] testArr.forEach((d) => { expect(dayjs().startOf(d).valueOf()).toBe(moment().startOf(d).valueOf()) expect(dayjs().endOf(d).valueOf()).toBe(moment().endOf(d).valueOf()) }) }) it('StartOf EndOf Other -> no change', () => { expect(dayjs().startOf('otherString').valueOf()).toBe(moment().startOf('otherString').valueOf()) expect(dayjs().endOf('otherString').valueOf()).toBe(moment().endOf('otherString').valueOf()) }) it('StartOf week with locale', () => { const testDate = [undefined, '2019-02-10', '2019-02-11', '2019-02-12', '2019-02-13', '2019-02-14', '2019-02-15', '2019-02-16'] const testLocale = ['zh-cn', 'ar', 'en'] testDate.forEach((d) => { testLocale.forEach((l) => { expect(dayjs(d).locale(l).startOf('week').date()) .toBe(moment(d).locale(l).startOf('week').date()) expect(dayjs(d).locale(l).endOf('week').date()) .toBe(moment(d).locale(l).endOf('week').date()) }) }) }) }) it('Add Time days', () => { expect(dayjs().add(1, 'ms').valueOf()).toBe(moment().add(1, 'ms').valueOf()) expect(dayjs().add(1, 'milliseconds').valueOf()).toBe(moment().add(1, 'milliseconds').valueOf()) expect(dayjs().add(1, 's').valueOf()).toBe(moment().add(1, 's').valueOf()) expect(dayjs().add(1, 'seconds').valueOf()).toBe(moment().add(1, 'seconds').valueOf()) expect(dayjs().add(1, 'm').valueOf()).toBe(moment().add(1, 'm').valueOf()) expect(dayjs().add(1, 'minutes').valueOf()).toBe(moment().add(1, 'minutes').valueOf()) expect(dayjs().add(1, 'h').valueOf()).toBe(moment().add(1, 'h').valueOf()) expect(dayjs().add(1, 'hours').valueOf()).toBe(moment().add(1, 'hours').valueOf()) expect(dayjs().add(1, 'w').valueOf()).toBe(moment().add(1, 'w').valueOf()) expect(dayjs().add(1, 'weeks').valueOf()).toBe(moment().add(1, 'weeks').valueOf()) expect(dayjs().add(1, 'd').valueOf()).toBe(moment().add(1, 'd').valueOf()) expect(dayjs().add(1, 'days').valueOf()).toBe(moment().add(1, 'days').valueOf()) expect(dayjs().add(1, 'M').valueOf()).toBe(moment().add(1, 'M').valueOf()) expect(dayjs().add(1, 'y').valueOf()).toBe(moment().add(1, 'y').valueOf()) expect(dayjs('20111031').add(1, 'months').valueOf()).toBe(moment('20111031').add(1, 'months').valueOf()) expect(dayjs('20160131').add(1, 'months').valueOf()).toBe(moment('20160131').add(1, 'months').valueOf()) expect(dayjs('20160229').add(1, 'year').valueOf()).toBe(moment('20160229').add(1, 'year').valueOf()) expect(dayjs().add('2', 'years').valueOf()).toBe(moment().add('2', 'years').valueOf()) }) it('Add Time with decimal', () => { expect(dayjs().add(0.4, 'day').valueOf()).toBe(moment().add(0.4, 'day').valueOf()) expect(dayjs().add(0.5, 'day').valueOf()).toBe(moment().add(0.5, 'day').valueOf()) expect(dayjs().add(0.4, 'week').valueOf()).toBe(moment().add(0.4, 'week').valueOf()) expect(dayjs().add(0.5, 'week').valueOf()).toBe(moment().add(0.5, 'week').valueOf()) }) it('Subtract Time days', () => { expect(dayjs().subtract(1, 'days').valueOf()).toBe(moment().subtract(1, 'days').valueOf()) }) ================================================ FILE: test/parse.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../src' import { REGEX_PARSE } from '../src/constant' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('Parse', () => { it('Now', () => { expect(dayjs().valueOf()).toBe(moment().valueOf()) }) it('moment-js like formatted dates', () => { global.console.warn = jest.genMockFunction()// moment.js '2018-4-1 1:1:1:22' will throw warn let d = '20130108' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) d = '2018-04-24' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) d = '2018-04-24 11:12' expect(dayjs(d).format()).toBe(moment(d).format()) // not recommend d = '2018-05-02 11:12:13' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) d = '2018-05-02 11:12:13.998' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) d = '2018-4-1' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) // not recommend d = '2018-4-1 11:12' expect(dayjs(d).format()).toBe(moment(d).format()) // not recommend d = '2018-4-1 1:1:1:223' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) // not recommend d = '2018-01' expect(dayjs(d).valueOf()).toBe(moment(d).valueOf()) // not recommend d = '2018' expect(dayjs(d).format()).toBe(moment(d).format()) // not recommend d = '2018-05-02T11:12:13Z' // should go direct to new Date() rather our regex expect(dayjs(d).format()).toBe(moment(d).format()) // not recommend }) it('String ISO 8601 date, time and zone', () => { const time = '2018-04-04T16:00:00.000Z' expect(dayjs(time).valueOf()).toBe(moment(time).valueOf()) }) it('String RFC 2822, time and zone', () => { const time = 'Mon, 11 Feb 2019 09:46:50 GMT+1' const expected = '2019-02-11T08:46:50.000Z' const d = dayjs(time) expect(d.toISOString()).toEqual(expected) expect(d.valueOf()).toBe(moment(time).valueOf()) }) it('String ECMAScript, time and zone', () => { // should parse dates formatted in ECMA script format // see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-date.prototype.tostring const time = 'Mon Feb 11 2019 11:01:37 GMT+0100 (Mitteleuropäische Normalzeit)' const expected = '2019-02-11T10:01:37.000Z' const d = dayjs(time) expect(d.toISOString()).toEqual(expected) expect(d.valueOf()).toBe(moment(time).valueOf()) }) it('rejects invalid values', () => { expect(dayjs({}).isValid()).toBe(false) expect(dayjs(() => '2018-01-01').isValid()).toBe(false) expect(dayjs(Infinity).isValid()).toBe(false) expect(dayjs(NaN).isValid()).toBe(false) expect(dayjs([2018, 5, 1, 13, 52, 44]).isValid()).toBe(false) // Arrays with time part }) it('parses Arrays with date part', () => { const dateParts = [2018, 5, 1] const expected = '2018-05-01T00:00:00.000Z' const d = dayjs(dateParts) const normalized = d.add(d.utcOffset(), 'minutes') // make test run in every timezone expect(normalized.toISOString()).toEqual(expected) }) it('parses unlimited millisecond', () => { const date = '2019-03-25T06:41:00.999999999' const ds = dayjs(date) const ms = moment(date) expect(ds.valueOf()).toEqual(ms.valueOf()) expect(ds.millisecond()).toEqual(ms.millisecond()) }) it('String Other, Undefined and Null and isValid', () => { global.console.warn = jest.genMockFunction()// moment.js otherString will throw warn expect(dayjs('otherString').toString().toLowerCase()).toBe(moment('otherString').toString().toLowerCase()) expect(dayjs(undefined).toDate()).toEqual(moment(undefined).toDate()) expect(dayjs().isValid()).toBe(true) expect(dayjs(undefined).isValid()).toBe(true) expect(dayjs('').isValid()).toBe(false) expect(dayjs(null).isValid()).toBe(false) expect(dayjs('otherString').isValid()).toBe(false) expect(dayjs(null).toString().toLowerCase()).toBe(moment(null).toString().toLowerCase()) }) }) it('Unix Timestamp Number (milliseconds) 1523520536000', () => { const timestamp = 1523520536000 expect(dayjs(timestamp).valueOf()).toBe(moment(timestamp).valueOf()) }) it('Unix Timestamp Number (seconds) 1318781876', () => { const timestamp1 = 1318781876 const timestamp2 = 1318781876.721 expect(dayjs.unix(timestamp1).valueOf()).toBe(moment.unix(timestamp1).valueOf()) expect(dayjs.unix(timestamp2).valueOf()).toBe(moment.unix(timestamp2).valueOf()) }) it('String and Number 20180101', () => { expect(dayjs(20180101).valueOf()).toBe(moment(20180101).valueOf()) expect(dayjs('20180101').valueOf()).toBe(moment('20180101').valueOf()) }) it('Number 0', () => { expect(dayjs(0).valueOf()).toBe(moment(0).valueOf()) }) it('Clone not affect each other', () => { const base = dayjs(20170101) const year = base.year() const another = base.set('year', year + 1) expect(another.unix() - base.unix()).toBe(31536000) }) it('Clone with same value', () => { const base = dayjs() const year = base.year() const newBase = base.set('year', year + 1) const another = newBase.clone() expect(newBase.toString()).toBe(another.toString()) }) describe('REGEX_PARSE', () => { it('2020/9/30', () => { const date = '2020/9/30' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('2020/9/30-2020-9-30----') }) it('2019-03-25T06:41:00.999999999', () => { const date = '2019-03-25T06:41:00.999999999' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('2019-03-25T06:41:00.999999999-2019-03-25-06-41-00-999999999') }) it('20210102T012345', () => { const date = '20210102T012345' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('20210102T012345-2021-01-02-01-23-45-') }) it('2021-01-02T01:23', () => { const date = '2021-01-02T01:23' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('2021-01-02T01:23-2021-01-02-01-23--') }) it('2021-01-02T01:23:45', () => { const date = '2021-01-02T01:23:45' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('2021-01-02T01:23:45-2021-01-02-01-23-45-') }) it('2020-12-31T18:00:00.000-0500 (no regex match)', () => { const date = '2020-12-31T18:00:00.000-0500' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d).toBe(null) }) // format used in timezone plugin utcString it('2021-1-4 0:42:53:000', () => { const date = '2021-1-4 0:42:53:000' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d.join('-')).toBe('2021-1-4 0:42:53:000-2021-1-4-0-42-53-000') }) it('2020-12-31T18:00:00-05:00 (no regex match)', () => { const date = '2020-12-31T18:00:00-05:00' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d).toBe(null) }) it('2021-01-02T01:23:45-0500 (no regex match)', () => { const date = '2021-01-02T01:23:45-0500' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d).toBe(null) }) it('2021-01-02T01:23:45Z (no regex match)', () => { const date = '2021-01-02T01:23:45Z' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d).toBe(null) }) // dots should not be matched, and fallback to Date it('2021.01.03', () => { const date = '2021.01.03' const d = date.match(REGEX_PARSE) expect(dayjs(date).valueOf()).toBe(moment(date).valueOf()) expect(d).toBe(null) }) }) ================================================ FILE: test/plugin/advancedFormat.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import advancedFormat from '../../src/plugin/advancedFormat' import isoWeek from '../../src/plugin/isoWeek' import weekOfYear from '../../src/plugin/weekOfYear' import weekYear from '../../src/plugin/weekYear' import timezone from '../../src/plugin/timezone' import utc from '../../src/plugin/utc' import '../../src/locale/zh-cn' import '../../src/locale/nl' dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(isoWeek) dayjs.extend(weekYear) dayjs.extend(weekOfYear) dayjs.extend(advancedFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format of invalid date', () => { expect(dayjs(null).format('z').toLowerCase()).toEqual(moment(null).format('z').toLowerCase()) }) it('Format empty string', () => { expect(dayjs().format()).toBe(moment().format()) }) it('Format Quarter Q', () => { expect(dayjs().format('Q')).toBe(moment().format('Q')) }) it('Format Timestamp X x', () => { expect(dayjs().format('X')).toBe(moment().format('X')) expect(dayjs().format('x')).toBe(moment().format('x')) }) it('Format Day of Month Do 1 - 31', () => { expect(dayjs().format('Do')).toBe(moment().format('Do')) let d = '2018-05-02 00:00:00.000' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-01 00:00:00.000' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-03 00:00:00.000' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-04 00:00:00.000' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-08 00:00:00.000' expect(dayjs(d).locale('nl').format('Do')).toBe(moment(d).locale('nl').format('Do')) d = '2018-05-11' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-12' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-13' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) d = '2018-05-19 00:00:00.000' expect(dayjs(d).locale('nl').format('Do')).toBe(moment(d).locale('nl').format('Do')) d = '2018-05-22' expect(dayjs(d).format('Do')).toBe(moment(d).format('Do')) }) it('Format Hour k kk 24-hour 1 - 24', () => { expect(dayjs().format('k')).toBe(moment().format('k')) expect(dayjs().format('kk')).toBe(moment().format('kk')) let d = '2018-05-02 00:00:00.000' expect(dayjs(d).format('k')).toBe('24') expect(dayjs(d).format('k')).toBe(moment(d).format('k')) expect(dayjs(d).format('kk')).toBe('24') expect(dayjs(d).format('kk')).toBe(moment(d).format('kk')) d = '2018-05-02 01:00:00.000' expect(dayjs(d).format('k')).toBe('1') expect(dayjs(d).format('k')).toBe(moment(d).format('k')) expect(dayjs(d).format('kk')).toBe('01') expect(dayjs(d).format('kk')).toBe(moment(d).format('kk')) d = '2018-05-02 23:59:59.999' expect(dayjs(d).format('k')).toBe('23') expect(dayjs(d).format('k')).toBe(moment(d).format('k')) expect(dayjs(d).format('kk')).toBe('23') expect(dayjs(d).format('kk')).toBe(moment(d).format('kk')) }) it('Format Week of Year wo', () => { const d = '2018-12-01' expect(dayjs(d).format('wo')).toBe(moment(d).format('wo')) expect(dayjs(d).locale('zh-cn').format('wo')) .toBe(moment(d).locale('zh-cn').format('wo')) }) it('Format Week of Year wo', () => { const d = '2018-12-01' expect(dayjs(d).format('wo')).toBe(moment(d).format('wo')) expect(dayjs(d).locale('zh-cn').format('wo')) .toBe(moment(d).locale('zh-cn').format('wo')) }) it('Format Week Year gggg', () => { const d = '2018-12-31' expect(dayjs(d).format('gggg')).toBe(moment(d).format('gggg')) }) it('Format Iso Week Year GGGG', () => { const d = '2021-01-01' expect(dayjs(d).format('GGGG')).toBe(moment(d).format('GGGG')) }) it('Format Iso Week of Year', () => { const d = '2021-01-01' expect(dayjs(d).format('W')).toBe(moment(d).format('W')) expect(dayjs(d).format('WW')).toBe(moment(d).format('WW')) }) it('Format offsetName z zzz', () => { const dtz = dayjs.tz('2012-03-11 01:59:59', 'America/New_York') expect(dtz.format('z')).toBe('EST') expect(dtz.format('zzz')).toBe('Eastern Standard Time') expect(dayjs().format('z')).toBeDefined() expect(dayjs().format('zzz')).toBeDefined() }) it('Skips format strings inside brackets', () => { expect(dayjs().format('[Q]')).toBe('Q') expect(dayjs().format('[Do]')).toBe('Do') expect(dayjs().format('[gggg]')).toBe('gggg') expect(dayjs().format('[GGGG]')).toBe('GGGG') expect(dayjs().format('[w]')).toBe('w') expect(dayjs().format('[ww]')).toBe('ww') expect(dayjs().format('[W]')).toBe('W') expect(dayjs().format('[WW]')).toBe('WW') expect(dayjs().format('[wo]')).toBe('wo') expect(dayjs().format('[k]')).toBe('k') expect(dayjs().format('[kk]')).toBe('kk') expect(dayjs().format('[X]')).toBe('X') expect(dayjs().format('[x]')).toBe('x') }) ================================================ FILE: test/plugin/arraySupport.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import arraySupport from '../../src/plugin/arraySupport' import utc from '../../src/plugin/utc' dayjs.extend(utc) dayjs.extend(arraySupport) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('parse empty array', () => { it('local', () => { expect(dayjs([]).format()) .toBe(moment([]).format()) }) it('utc', () => { expect(dayjs.utc([]).format()) .toBe(moment.utc([]).format()) }) }) const testArrs = [ [2010, 1, 14, 15, 25, 50, 125], [2010], [2010, 6], [2010, 6, 10] ] describe('parse array local', () => { testArrs.forEach((testArr) => { it(testArr, () => { expect(dayjs(testArr).format()) .toBe(moment(testArr).format()) }) }) }) describe('parse array utc', () => { testArrs.forEach((testArr) => { it(testArr, () => { expect(dayjs.utc(testArr).format()) .toBe(moment.utc(testArr).format()) }) }) }) ================================================ FILE: test/plugin/badMutable.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import badMutable from '../../src/plugin/badMutable' import dayOfYear from '../../src/plugin/dayOfYear' import weekOfYear from '../../src/plugin/weekOfYear' import '../../src/locale/zh-cn' dayjs.extend(badMutable) dayjs.extend(dayOfYear) dayjs.extend(weekOfYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('Set', () => { it('Setters', () => { const d = dayjs() const m = moment() expect(d.year()).toBe(m.year()) d.year(2000) m.year(2000) expect(d.format()).toBe(m.format()) d.month(1) m.month(1) expect(d.format()).toBe(m.format()) d.day(1) m.day(1) expect(d.format()).toBe(m.format()) d.date(1) m.date(1) expect(d.format()).toBe(m.format()) d.hour(1) m.hour(1) expect(d.format()).toBe(m.format()) d.minute(1) m.minute(1) expect(d.format()).toBe(m.format()) d.second(1) m.second(1) expect(d.format()).toBe(m.format()) d.millisecond(1) m.millisecond(1) expect(d.format()).toBe(m.format()) }) it('Set', () => { const d = dayjs() const m = moment() d.set('year', 2000) m.set('year', 2000) expect(d.format()).toBe(m.format()) d.set('month', 12) m.set('month', 12) expect(d.format()).toBe(m.format()) d.set('day', 1) m.set('day', 1) expect(d.format()).toBe(m.format()) d.set('date', 1) m.set('date', 1) expect(d.format()).toBe(m.format()) d.set('hour', 1) m.set('hour', 1) expect(d.format()).toBe(m.format()) d.set('minute', 1) m.set('minute', 1) expect(d.format()).toBe(m.format()) d.set('second', 1) m.set('second', 1) expect(d.format()).toBe(m.format()) d.set('millisecond', 1) m.set('millisecond', 1) expect(d.format()).toBe(m.format()) }) }) describe('StartOf', () => { it('StartOf', () => { const d = dayjs() const m = moment() d.startOf('year') m.startOf('year') expect(d.format()).toBe(m.format()) d.startOf('month') m.startOf('month') expect(d.format()).toBe(m.format()) d.startOf('day') m.startOf('day') expect(d.format()).toBe(m.format()) d.startOf('date') m.startOf('date') expect(d.format()).toBe(m.format()) d.startOf('hour') m.startOf('hour') expect(d.format()).toBe(m.format()) d.startOf('minute') m.startOf('minute') expect(d.format()).toBe(m.format()) d.startOf('second') m.startOf('second') expect(d.format()).toBe(m.format()) d.startOf('millisecond') m.startOf('millisecond') expect(d.format()).toBe(m.format()) d.startOf('week') m.startOf('week') expect(d.format()).toBe(m.format()) }) }) describe('Add', () => { it('Add', () => { const d = dayjs() const m = moment() d.add(1, 'year') m.add(1, 'year') expect(d.format()).toBe(m.format()) d.add(12, 'month') m.add(12, 'month') expect(d.format()).toBe(m.format()) d.add(1, 'day') m.add(1, 'day') expect(d.format()).toBe(m.format()) d.add(1, 'date') m.add(1, 'date') expect(d.format()).toBe(m.format()) d.add(1, 'hour') m.add(1, 'hour') expect(d.format()).toBe(m.format()) d.add(1, 'minute') m.add(1, 'minute') expect(d.format()).toBe(m.format()) d.add(1, 'second') m.add(1, 'second') expect(d.format()).toBe(m.format()) d.add(1, 'millisecond') m.add(1, 'millisecond') expect(d.format()).toBe(m.format()) d.add(1, 'week') m.add(1, 'week') expect(d.format()).toBe(m.format()) }) }) it('daysInMonth', () => { const d = dayjs() const m = moment() expect(d.daysInMonth()).toBe(m.daysInMonth()) expect(d.format()).toBe(m.format()) }) it('Locale', () => { const d = dayjs() const m = moment() const format = 'MMMM' expect(d.locale()).toBe(m.locale()) expect(d.format(format)).toBe(m.format(format)) d.locale('zh-cn') m.locale('zh-cn') expect(d.locale()).toBe(m.locale()) expect(d.format(format)).toBe(m.format(format)) }) it('Diff', () => { const d = dayjs() const m = moment() const unit = 'year' const d2 = d.clone().add(1, unit) const m2 = m.clone().add(1, unit) expect(d.diff(d2, unit)).toBe(-1) expect(m.diff(m2, unit)).toBe(-1) }) it('isAfter isBefore isSame', () => { const d = dayjs() const format = dayjs().format() d.isSame(dayjs, 'year') expect(d.format()).toBe(format) expect(d.isSame()).toBe(true) d.isBefore(dayjs, 'hour') expect(d.format()).toBe(format) expect(d.isBefore()).toBe(false) d.isAfter(dayjs, 'month') expect(d.format()).toBe(format) expect(d.isAfter()).toBe(false) }) it('DayOfYear get day won\'t change instance', () => { const d = dayjs() const format = d.format() d.dayOfYear() expect(d.format()).toBe(format) }) it('WeekOfYear get week won\'t change instance', () => { const d = dayjs() const format = d.format() d.week() expect(d.format()).toBe(format) }) ================================================ FILE: test/plugin/bigIntSupport.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import bigIntSupport from '../../src/plugin/bigIntSupport' dayjs.extend(bigIntSupport) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) /* global BigInt */ it('Parse BigInt ts and tsms', () => { const tsms = 1666310421101 const tsmsBig = BigInt(tsms) const ts = 1666311003 const tsBig = BigInt(ts) const momentTsms = moment(tsms) const momentTs = moment.unix(ts) expect(dayjs(tsms).valueOf()).toBe(momentTsms.valueOf()) expect(dayjs(tsms).valueOf()).toBe(dayjs(tsmsBig).valueOf()) expect(dayjs.unix(ts).valueOf()).toBe(momentTs.valueOf()) expect(dayjs.unix(tsBig).valueOf()).toBe(dayjs.unix(tsBig).valueOf()) }) ================================================ FILE: test/plugin/buddhistEra.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import buddhistEra from '../../src/plugin/buddhistEra' dayjs.extend(buddhistEra) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format empty string', () => { expect(dayjs().format()).toBe(moment().format()) }) it('Format Buddhist Era 2 digit', () => { expect(dayjs().format('BB')).toBe(`${(moment().year() + 543) % 100}`) }) it('Format Buddhist Era 4 digit', () => { expect(dayjs().format('BBBB')).toBe(`${moment().year() + 543}`) }) it('Format Buddhist Era 4 digit with other format', () => { const format = 'D MMM BBBB' const today = moment() const momentDate = today.format(format).replace('BBBB', today.year() + 543) expect(dayjs().format(format)).toBe(momentDate) }) it('Skips format strings inside brackets', () => { expect(dayjs().format('[BBBB]')).toBe('BBBB') expect(dayjs().format('[BB]')).toBe('BB') }) ================================================ FILE: test/plugin/calendar.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import calendar from '../../src/plugin/calendar' import zhCn from '../../src/locale/zh-cn' dayjs.extend(calendar) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('No argument && null && undefined', () => { expect(dayjs().calendar()).toEqual(moment().calendar()) // moment@2.27.0 does not support calendar(null) calendar(undefined) }) it('ReferenceTime', () => { const now = '2015-01-15T14:21:22.000Z' const dates = [ { name: 'nextDay', date: '2015-01-14T11:23:55.000Z', result: 'Tomorrow' }, { name: 'sameDay', date: '2015-01-15T11:23:55.000Z', result: 'Today' }, { name: 'nextWeek', date: '2015-01-09T11:23:55.000Z', result: 'Thursday' }, { name: 'lastDay', date: '2015-01-16T11:23:55.000Z', result: 'Yesterday' }, { name: 'lastWeek', date: '2015-01-21T11:23:55.000Z', result: 'Last' }, { name: 'sameElse', date: '2015-01-01T11:23:55.000Z', result: '01/15/2015' }, { name: 'sameElse', date: '2015-02-21T11:23:55.000Z', result: '01/15/2015' } ] dates.forEach((d) => { const dayjsResult = dayjs(now).calendar(d.date) const momentjsResult = moment(now).calendar(d.date) expect(dayjsResult) .toEqual(momentjsResult) expect(dayjsResult.indexOf(d.result) > -1) .toBe(true) }) }) it('Custom format', () => { const format = { sameDay: '[sameDay]', sameElse: '[sameElse]' } expect(dayjs().calendar(null, format)).toEqual(moment().calendar(null, format)) const now = '2015-01-15T14:21:22.000Z' const nextDayWithoutFormat = '2015-01-14T11:23:55.000Z' expect(dayjs(now).calendar(nextDayWithoutFormat, format)) .toEqual(moment(now).calendar(nextDayWithoutFormat, format)) }) it('Custom callback', () => { const callbacks = { sameDay: jest.fn(), sameElse: jest.fn() } const now = '2015-01-15T14:21:22.000Z' const nextDayWithoutFormat = '2015-01-14T11:23:55.000Z' expect(dayjs(now).calendar(nextDayWithoutFormat, callbacks)) .toEqual(moment(now).calendar(nextDayWithoutFormat, callbacks)) }) it('Calls callback', () => { const callbacks = { sameDay: jest.fn(), sameElse: jest.fn() } dayjs().calendar(null, callbacks) expect(callbacks.sameElse).not.toBeCalled() expect(callbacks.sameDay).toBeCalled() }) it('callback is a function with the scope of the current moment', () => { const callbacks = { sameDay: jest.fn() } expect(dayjs().calendar(null, callbacks)).toEqual(callbacks.sameDay()) const callbacks2 = { sameDay: function cb() { return this } } const result = dayjs().calendar(null, callbacks2) expect(result.format).not.toBeUndefined() expect(dayjs.isDayjs(result)).toBeTruthy() }) it('callback is a function and first argument a moment that depicts now', () => { const callbacks = { sameDay: jest.fn() } const now = dayjs() dayjs(now).calendar(now, callbacks) expect(callbacks.sameDay).toBeCalledWith(now) }) it('set global calendar in locale file', () => { const now = '2019-04-03T14:21:22.000Z' zhCn.calendar = { sameDay: '[今天]HH:mm', nextDay: '[明天]HH:mm', nextWeek: '[下]ddddHH:mm', lastDay: '[昨天]HH:mm', lastWeek: '[上]ddddHH:mm', sameElse: 'YYYY/MM/DD' } dayjs.locale(zhCn) expect(dayjs(now).calendar()) .toEqual(moment(now).locale('zh-cn').calendar()) }) ================================================ FILE: test/plugin/customParseFormat.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import '../../src/locale/ru' import uk from '../../src/locale/uk' import '../../src/locale/zh-cn' import customParseFormat from '../../src/plugin/customParseFormat' import advancedFormat from '../../src/plugin/advancedFormat' import localizedFormats from '../../src/plugin/localizedFormat' import weekOfYear from '../../src/plugin/weekOfYear' dayjs.extend(customParseFormat) dayjs.extend(localizedFormats) dayjs.extend(weekOfYear) // test parse w, ww beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('does not break the built-in parsing', () => { const input = '2018-05-02 01:02:03.004' expect(dayjs(input).valueOf()).toBe(moment(input).valueOf()) }) it('parse padded string', () => { const input = '2018-05-02 01:02:03.004 AM +01:00' const format = 'YYYY-MM-DD HH:mm:ss.SSS A Z' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse string for MMM month format', () => { const input = '4/Mar/2019:11:16:26 +0800' const format = 'D/MMM/YYYY:H:m:s zz' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '21-Dec-18' const format2 = 'D-MMM-YY' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) it('parse string January (getMonth() = 0)', () => { const input = '01/01/2019' const format = 'DD/MM/YYYY' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse unpadded string', () => { const input = '2.5.18 1:2:3.4 PM -0100' const format = 'D.M.YY H:m:s.S A ZZ' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse time zone abbreviation', () => { const input = '05/02/69 1:02:03.004 AM +01:00 (CET)' const format = 'MM/DD/YY h:mm:ss.SSS A Z (z)' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse time zone abbreviation2', () => { const input = '05/02/69 1:02:03.04 AM +01:00 (CET)' const format = 'MM/DD/YY h:mm:ss.SS A Z (z)' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('recognizes midnight in small letters', () => { const input = '2018-05-02 12:00 am' const format = 'YYYY-MM-DD hh:mm a' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('recognizes noon in small letters', () => { const input = '2018-05-02 12:00 pm' const format = 'YYYY-MM-DD hh:mm a' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) describe('parse localizedFormats', () => { ['zh-cn', 'ru', 'uk', 'en'].forEach((lo) => { it(`Locale: ${lo}`, () => { const input = '2018-05-02 01:02:03.004' dayjs.locale(lo) moment.locale(lo) const longDateFormats = ['LT', 'LTS', 'L', 'LL', 'l', 'll', 'lll', 'l LT', 'LL [l] LTS'] // TODO: fix LLL, LLLL and llll longDateFormats.forEach((f) => { const localizedInput = moment(input).format(f) expect(dayjs(localizedInput, f).valueOf()).toBe(moment(localizedInput, f).valueOf()) }) }) }) }) it('leaves non-token parts of the format intact', () => { const input = '2018-05-02 12:00 +0000 S:/-.() SS h ' const format = 'YYYY-MM-DD HH:mm ZZ [S]:/-.()[ SS h ]' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('timezone with no hour', () => { const input = '2018-05-02 +0000' const format = 'YYYY-MM-DD ZZ' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) describe('Timezone Offset', () => { it('timezone with 2-digit offset', () => { const input = '2020-12-01T20:00:00+09' const format = 'YYYY-MM-DD[T]HH:mm:ssZZ' const result = dayjs(input, format) expect(result.valueOf()).toBe(moment(input, format).valueOf()) expect(result.valueOf()).toBe(1606820400000) }) it('zulu', () => { const input = '2021-01-26T15:38:43.000Z' const format = 'YYYY-MM-DDTHH:mm:ss.SSSZ' const result = dayjs(input, format) expect(result.valueOf()).toBe(moment(input, format).valueOf()) expect(result.valueOf()).toBe(1611675523000) }) it('no timezone format token should parse in local time', () => { const input = '2020-12-01T20:00:00+01:00' const format = 'YYYY-MM-DD[T]HH:mm:ss' const result = dayjs(input, format) expect(result.valueOf()).toBe(moment(input, format).valueOf()) }) }) it('parse hh:mm', () => { const input = '12:00' const format = 'hh:mm' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse HH:mm:ss', () => { const input = '00:27:21' const format = 'HH:mm:ss' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse HH:mm:ss but only one digit', () => { const input = '0:0:1' const format = 'HH:mm:ss' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) describe('parse YYYY / YYYY-MM only', () => { it('YYYY', () => { const input = '2001 +08:00' const format = 'YYYY Z' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '2001' const format2 = 'YYYY' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) it('YYYY-MM', () => { const input = '2001-01 +08:00' const format = 'YYYY-MM Z' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '2001-01' const format2 = 'YYYY-MM' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) }) it('parse hh:mm:ss but only one digit', () => { const input = '0:0:1' const format = 'hh:mm:ss' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('fails with an invalid format', () => { const input = '2018-05-02 12:00 PM' const format = 'C' expect(dayjs(input, format).format().toLowerCase()) .toBe(moment(input, format).format().toLowerCase()) }) it('parse month from string', () => { const input = '2018 February 03' const format = 'YYYY MMMM DD' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '21-December-18' const format2 = 'D-MMMM-YY' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) it('parse month from short string', () => { const input = '2018 Feb 03' const format = 'YYYY MMM DD' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) }) it('parse month from string with locale in config', () => { const input = '2018 лютий 03' const format = 'YYYY MMMM DD' expect(dayjs(input, format, 'uk').valueOf()).toBe(moment(input, format, 'uk').valueOf()) }) it('parse month from short string with locale in config', () => { const input = '2018 трав 03' const format = 'YYYY MMM DD' expect(dayjs(input, format, 'uk').valueOf()).toBe(moment(input, format, 'uk').valueOf()) }) it('parse month from short string with locale in argument', () => { const input = '2018 трав 03' const format = 'YYYY MMM DD' expect(dayjs(input, format, 'uk').valueOf()).toBe(moment(input, format, 'uk').valueOf()) }) it('parse month from string with locale in argument', () => { const input = '2018 лютий 03' const format = 'YYYY MMMM DD' expect(dayjs(input, format, 'uk').valueOf()).toBe(moment(input, format, 'uk').valueOf()) }) it('return Invalid Date when parse corrupt string', () => { const input = '2018 Turnip 03' const format = 'YYYY MMMM DD' expect(dayjs(input, format).format()).toBe('Invalid Date') }) it('return Invalid Date when parse corrupt short string', () => { const input = '2018 Dog 03' const format = 'YYYY MMM DD' expect(dayjs(input, format).format()).toBe('Invalid Date') }) it('YYYY-MM set 1st day of the month', () => { expect(dayjs('2019-02', 'YYYY-MM').format('YYYY-MM-DD')).toBe('2019-02-01') }) it('Invalid Dates', () => { expect(dayjs('10/12/2014', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('Invalid Date') expect(dayjs('10-12-2014', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('Invalid Date') }) it('Valid Date', () => { expect(dayjs('2014/10/12', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('10-12-2014') }) it('correctly parse month from string after changing locale globally', () => { const input = '2018 лютий 03' const format = 'YYYY MMMM DD' const dayjsLocale = dayjs().$locale() const momentLocale = moment.locale() try { dayjs.locale(uk) moment.locale('uk') expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) } finally { dayjs.locale(dayjsLocale) moment.locale(momentLocale) } }) it('correctly parse ordinal', () => { const input = '7th March 2019' const input2 = '17th March 2019' const inputFalse = '7st March 2019' const inputZHCN = '7日 三月 2019' const format = 'Do MMMM YYYY' const displayFormatWithLocale = 'MMMM dddd' expect(dayjs(input, format).valueOf()) .toBe(moment(input, format).valueOf()) expect(dayjs(input2, format).valueOf()) .toBe(moment(input2, format).valueOf()) expect(dayjs(inputFalse, format).valueOf()) .toBe(moment(inputFalse, format).valueOf()) const dayjsCN = dayjs(inputZHCN, format, 'zh-cn') const momentCN = moment(inputZHCN, format, 'zh-cn') expect(dayjsCN.valueOf()) .toBe(momentCN.valueOf()) expect(dayjsCN.format(displayFormatWithLocale)) .toBe(momentCN.format(displayFormatWithLocale)) expect(dayjsCN.locale()) .toBe(momentCN.locale()) }) describe('month function locale', () => { it('MMMM', () => { const input = '08 мая 2020' const input2 = '08 май 2020' const format = 'DD MMMM YYYY' expect(dayjs(input, format, 'ru').valueOf()).toBe(moment(input, format, 'ru').valueOf()) expect(dayjs(input2, format, 'ru').valueOf()).toBe(moment(input2, format, 'ru').valueOf()) }) it('MMM', () => { const input = '08 февр. 2020' const format = 'DD MMM YYYY' expect(dayjs(input, format, 'ru').valueOf()).toBe(moment(input, format, 'ru').valueOf()) }) }) describe('Strict mode', () => { it('without locale', () => { const input = '1970-00-00' const format = 'YYYY-MM-DD' expect(dayjs(input, format).isValid()).toBe(true) expect(dayjs(input, format, true).isValid()).toBe(false) expect(dayjs('2020-Jan-01', 'YYYY-MMM-DD', true).isValid()).toBe(true) expect(dayjs('30/1/2020 10:59 PM', 'D/M/YYYY h:mm A', true).isValid()).toBe(true) }) it('with locale', () => { const input = '2018 三月 99' const format = 'YYYY MMMM DD' expect(dayjs(input, format, 'zh-cn').isValid()).toBe(true) expect(dayjs(input, format, 'zh-cn', true).isValid()).toBe(false) }) }) describe('Array format support', () => { it('second ok', () => { const input = '2012-05-28' const format = ['YYYY', 'YYYY-MM-DD'] expect(dayjs(input, format).isValid()).toBe(true) expect(dayjs(input, format, true).format('YYYY-MM-DD')).toBe('2012-05-28') }) it('all invalid', () => { const input = '2012-05-28' const format = ['DD', 'MM-DD'] expect(dayjs(input, format, true).isValid()).toBe(false) }) it('with locale', () => { const input = '2018 三月 12' const format = ['YYYY', 'MM', 'YYYY MMMM DD'] expect(dayjs(input, format, 'zh-cn', true).format('YYYY MMMM DD')).toBe(input) }) }) describe('meridiem locale', () => { const format = 'YYYY年M月D日Ah点mm分ss秒' const format2 = 'YYYY-MM-DD HH:mm:ss' it('AM', () => { const input = '2018-05-02 01:02:03' const date = dayjs(input).locale('zh-cn').format(format) expect(dayjs(date, format, 'zh-cn').format(format2)).toBe(input) }) it('PM', () => { const input = '2018-05-02 20:02:03' const date = dayjs(input).locale('zh-cn').format(format) expect(dayjs(date, format, 'zh-cn').format(format2)).toBe(input) }) }) it('parse a string for MMM month format with underscore delimiter', () => { const input = 'Jan_2021' const format = 'MMM_YYYY' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '21_Jan_2021_123523' const format2 = 'DD_MMM_YYYY_hhmmss' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) it('custom two-digit year parse function', () => { delete customParseFormat.$i // this allow plugin to be installed again dayjs.extend(customParseFormat, { parseTwoDigitYear: yearString => (+yearString) + 1800 }) const format = 'YY-MM-DD' const input = '00-05-02' expect(dayjs(input, format).year()).toBe(1800) const input2 = '50-05-02' expect(dayjs(input2, format).year()).toBe(1850) const input3 = '99-05-02' expect(dayjs(input3, format).year()).toBe(1899) }) // issue 1852 describe('parse with special separator characters', () => { it('Output is NaN for a specific date format', () => { const input = '20 Nov, 2022' const format = 'DD MMM, YYYY' const locale = 'en' const resultDayjs = dayjs(input, format, locale) const resultMoment = moment(input, format, locale) expect(resultMoment.isValid()).toBe(true) expect(resultDayjs.isValid()).toBe(true) expect(resultDayjs.format('DD-MM-YYYY')).toBe('20-11-2022') expect(resultMoment.format('DD-MM-YYYY')).toBe('20-11-2022') }) it('parse comma separated date', () => { const input = '20,11,2022' const format = 'DD,MM,YYYY' const resultDayjs = dayjs(input, format) const resultMoment = moment(input, format) expect(resultMoment.isValid()).toBe(true) expect(resultDayjs.isValid()).toBe(true) expect(resultDayjs.format('DD-MM-YYYY')).toBe('20-11-2022') expect(resultMoment.format('DD-MM-YYYY')).toBe('20-11-2022') }) it('parse comma separated date in strict mode', () => { const input = '20,11,2022' const format = 'DD,MM,YYYY' const resultDayjs = dayjs(input, format, true) const resultMoment = moment(input, format, true) expect(resultMoment.isValid()).toBe(true) expect(resultDayjs.isValid()).toBe(true) expect(resultDayjs.format('DD-MM-YYYY')).toBe('20-11-2022') expect(resultMoment.format('DD-MM-YYYY')).toBe('20-11-2022') }) it('parse date with multi character separator', () => { const input = '20---11---2022' const format = 'DD-/-MM-#-YYYY' const resultDayjs = dayjs(input, format) const resultMoment = moment(input, format) expect(resultMoment.isValid()).toBe(true) expect(resultDayjs.isValid()).toBe(true) expect(resultDayjs.format('DD-MM-YYYY')).toBe('20-11-2022') expect(resultMoment.format('DD-MM-YYYY')).toBe('20-11-2022') }) it('parse date with multi character separator in strict mode', () => { const input = '20-/-11-#-2022' const format = 'DD-/-MM-#-YYYY' const resultDayjs = dayjs(input, format, true) const resultMoment = moment(input, format, true) expect(resultMoment.isValid()).toBe(true) expect(resultDayjs.isValid()).toBe(true) expect(resultDayjs.format('DD-MM-YYYY')).toBe('20-11-2022') expect(resultMoment.format('DD-MM-YYYY')).toBe('20-11-2022') }) }) it('parse X x', () => { const input = '1410715640.579' const format = 'X' expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf()) const input2 = '1410715640579' const format2 = 'x' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) // x X starct parse requires advancedFormat plugin dayjs.extend(advancedFormat) expect(dayjs(input2, format2, true).valueOf()).toBe(moment(input2, format2, true).valueOf()) }) it('parse Q, [Q]', () => { const input1 = '2024-Q1' const input2 = '2024-Q2' const input3 = '2024-Q3' const input4 = '2024-Q4' const format = 'YYYY-[Q]Q' expect(dayjs(input1, format).valueOf()).toBe(moment(input1, format).valueOf()) expect(dayjs(input2, format).valueOf()).toBe(moment(input2, format).valueOf()) expect(dayjs(input3, format).valueOf()).toBe(moment(input3, format).valueOf()) expect(dayjs(input4, format).valueOf()).toBe(moment(input4, format).valueOf()) }) it('parse w, ww', () => { const input = '2024-w1' const format1 = 'YYYY-[w]w' expect(dayjs(input, format1).format(format1)).toBe(input) const input2 = '2024-w32' const format2 = 'YYYY-[w]ww' expect(dayjs(input2, format2).format(format1)).toBe(input2) }) ================================================ FILE: test/plugin/dayOfYear.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import dayOfYear from '../../src/plugin/dayOfYear' dayjs.extend(dayOfYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('DayOfYear get', () => { expect(dayjs().dayOfYear()).toBe(moment().dayOfYear()) expect(dayjs('2015-01-01T00:00:00.000').dayOfYear()).toBe(1) expect(dayjs('2015-01-31T00:00:00.000').dayOfYear()).toBe(31) expect(dayjs('2015-02-01T00:00:00.000').dayOfYear()).toBe(32) expect(dayjs('2015-02-28T00:00:00.000').dayOfYear()).toBe(59) expect(dayjs('2015-12-31T00:00:00.000').dayOfYear()).toBe(365) }) it('DayOfYear set', () => { expect(dayjs().dayOfYear(4).dayOfYear()).toBe(moment().dayOfYear(4).dayOfYear()) expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(4) .dayOfYear()).toBe(4) expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(4) .toISOString()).toBe('2015-01-04T00:00:00.000Z') expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(32) .dayOfYear()).toBe(32) expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(32) .toISOString()).toBe('2015-02-01T00:00:00.000Z') expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(365) .dayOfYear()).toBe(365) expect(dayjs('2015-01-01T00:00:00.000Z') .dayOfYear(365) .toISOString()).toBe('2015-12-31T00:00:00.000Z') }) ================================================ FILE: test/plugin/declarations.test.js ================================================ import fs from 'fs' import path from 'path' const pluginDir = '../../src/plugin' const pluginTypeDir = '../../types/plugin' it('Plugin declarations', () => { fs.readdirSync(path.join(__dirname, pluginDir)) .forEach((l) => { expect(fs.existsSync(path.join(__dirname, pluginTypeDir, `${l}.d.ts`))) .toBe(true) }) }) ================================================ FILE: test/plugin/devHelper.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import customParseFormat from '../../src/plugin/customParseFormat' import devHelper from '../../src/plugin/devHelper' import localeData from '../../src/plugin/localeData' dayjs.extend(devHelper) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) global.console.warn = jest.genMockFunction() it('Warning: passing Year as a Number will be parsed as a Unix timestamp', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs(2020) expect(consoleSpy).toHaveBeenCalledWith('Guessing you may want to parse the Year 2020, you should pass it as a String 2020, not a Number. Otherwise, 2020 will be treated as a Unix timestamp') }) it('Warning Passing Unix timestamp as a String not Number', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('1231231231231') expect(consoleSpy).toHaveBeenCalledWith('To parse a Unix timestamp like 1231231231231, you should pass it as a Number. https://day.js.org/docs/en/parse/unix-timestamp-milliseconds') }) it('Warning Enable customParseFormat plugin while passing the second format parameter', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2020', 'YYYY') expect(consoleSpy).toHaveBeenCalledWith('To parse a date-time string like 2020 using the given format, you should enable customParseFormat plugin first. https://day.js.org/docs/en/parse/string-format') }) it('Warning: Setting locale before loading locale', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs.locale('zh-cn') expect(consoleSpy).toHaveBeenCalledWith('Guessing you may want to use locale zh-cn, you have to load it before using it. https://day.js.org/docs/en/i18n/loading-into-nodejs') }) describe('dev-helper: diff() usage warnings', () => { const diffWarningMsg = 'Invalid usage: diff() requires a valid comparison date as the first argument. https://day.js.org/docs/en/display/difference' beforeAll(() => { dayjs.extend(customParseFormat) dayjs.extend(localeData) }) beforeEach(() => { jest.clearAllMocks() }) it('warns when diff() is called with no comparison date', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2025-01-10').diff() expect(consoleSpy).toHaveBeenCalledWith(diffWarningMsg) }) it('warns when diff() is called with just the unit', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2025-01-10').diff('days') expect(consoleSpy).toHaveBeenCalledWith(diffWarningMsg) }) it('warns when diff() is called with an invalid comparison date (unparsable string)', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2025-01-10').diff('invalid-date', 'days') expect(consoleSpy).toHaveBeenCalledWith(diffWarningMsg) }) it('does NOT warn when diff() is called with a valid string date', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2025-01-10').diff('2025-01-09', 'days') expect(consoleSpy).not.toHaveBeenCalledWith(diffWarningMsg) }) it('does NOT warn when diff() is called with a valid Day.js instance', () => { const consoleSpy = jest.spyOn(console, 'warn') dayjs('2025-01-10').diff(dayjs(), 'days') expect(consoleSpy).not.toHaveBeenCalledWith(diffWarningMsg) }) }) ================================================ FILE: test/plugin/duration.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import duration from '../../src/plugin/duration' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/fr' import '../../src/locale/es' dayjs.extend(relativeTime) dayjs.extend(duration) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('Creating', () => { it('no argument', () => { expect(dayjs.duration().toISOString()).toBe('P0D') expect(dayjs.duration().asMilliseconds()).toBe(0) }) it('milliseconds', () => { expect(dayjs.duration(1, 'ms').toISOString()).toBe('PT0.001S') expect(dayjs.duration(100).toISOString()).toBe('PT0.1S') expect(dayjs.duration(1000).toISOString()).toBe('PT1S') }) it('two argument will bubble up to the next', () => { expect(dayjs.duration(59, 'seconds').toISOString()).toBe('PT59S') expect(dayjs.duration(60, 'seconds').toISOString()).toBe('PT1M') expect(dayjs.duration(13213, 'seconds').toISOString()).toBe('PT3H40M13S') }) it('two argument will bubble up to the next (negative number)', () => { expect(dayjs.duration(-59, 'seconds').toISOString()).toBe('-PT59S') expect(dayjs.duration(-60, 'seconds').toISOString()).toBe('-PT1M') expect(dayjs.duration(-13213, 'seconds').toISOString()).toBe('-PT3H40M13S') }) it('object with float', () => { expect(dayjs.duration({ seconds: 1, minutes: 2, hours: 3, days: 4, months: 6, years: 7 }).toISOString()).toBe('P7Y6M4DT3H2M1S') }) it('object with weeks and float', () => { expect(dayjs.duration({ seconds: 1.1, minutes: 2, hours: 3, days: 4, weeks: 5, months: 6, years: 7 }).toISOString()).toBe('P7Y6M39DT3H2M1.1S') }) it('object with millisecond', () => { expect(dayjs.duration({ ms: 1 }).toISOString()).toBe('PT0.001S') }) it('object with negative millisecond', () => { expect(dayjs.duration({ ms: -1 }).toISOString()).toBe('-PT0.001S') }) it('convert to milliseconds', () => { expect(+dayjs.duration(100)).toBe(100) }) it('handles rounding to millisecond precision', () => { expect(dayjs.duration(2 / 3).toISOString()).toBe('PT0.001S') }) it('should handle round with millisecond precision when negative', () => { expect(dayjs.duration(1000.5).toISOString()).toBe('PT1.001S') expect(dayjs.duration(-1000.5).toISOString()).toBe('-PT1S') }) it('should handle floating point rounding errors', () => { // An example of this is when adding 2 to 0.812 seconds, which is how // the seconds component is calculated in .toISOString(). // > 2 + 0.812 // 2.8120000000000003 expect(dayjs.duration(-2812).toISOString()).toBe('-PT2.812S') // was -PT2.8120000000000003S expect(dayjs.duration(3121632.27382247).toISOString()).toBe('PT52M1.632S') // was PT52M1.6320000000000001S expect(dayjs.duration(7647826.525774224).toISOString()).toBe('PT2H7M27.827S') // was PT2H7M27.826999999999998S }) }) describe('Parse ISO string', () => { it('Full ISO string', () => { expect(dayjs.duration('P7Y6M4DT3H2M1S').toISOString()).toBe('P7Y6M4DT3H2M1S') }) it('Part ISO string', () => { expect(dayjs.duration('PT2777H46M40S').toISOString()).toBe('PT2777H46M40S') }) it('Formatting missing components', () => { expect(dayjs.duration('PT1H').format('YYYY-MM-DDTHH:mm:ss')).toBe('0000-00-00T01:00:00') }) it('ISO string with week', () => { const d = dayjs.duration('P2M3W4D') expect(d.toISOString()).toBe('P2M25D') expect(d.asDays()).toBe(85.83333333333333) // moment 86, count 2M as 61 days expect(d.asWeeks()).toBe(12.261904761904763) // moment 12.285714285714286 expect(d.asMonths()).toBe(2.8219178082191783) // moment 2.8213721020965523 }) it('Invalid ISO string', () => { expect(dayjs.duration('Invalid').toISOString()).toBe('P0D') }) }) it('Is duration', () => { expect(dayjs.isDuration(dayjs.duration())).toBe(true) expect(dayjs.isDuration(dayjs.duration(1))).toBe(true) expect(dayjs.isDuration(dayjs())).toBe(false) expect(dayjs.isDuration({})).toBe(false) expect(dayjs.isDuration()).toBe(false) }) it('toJSON', () => { expect(JSON.stringify({ postDuration: dayjs.duration(5, 'minutes') })).toBe('{"postDuration":"PT5M"}') }) describe('Humanize', () => { it('Humaniz', () => { expect(dayjs.duration(1, 'minutes').humanize()).toBe('a minute') expect(dayjs.duration(2, 'minutes').humanize()).toBe('2 minutes') expect(dayjs.duration(24, 'hours').humanize()).toBe('a day') expect(dayjs.duration(1, 'minutes').humanize(true)).toBe('in a minute') expect(dayjs.duration(-1, 'minutes').humanize(true)).toBe('a minute ago') }) it('Locale', () => { expect(dayjs.duration(1, 'minutes').humanize(true)).toBe('in a minute') expect(dayjs.duration(1, 'minutes').locale('fr').humanize(true)).toBe('dans une minute') expect(dayjs.duration(1, 'minutes').locale('es').humanize(true)).toBe('en un minuto') }) it('Global Locale', () => { dayjs.locale('en') expect(dayjs.duration(1, 'minutes').humanize(true)).toBe('in a minute') dayjs.locale('fr') expect(dayjs.duration(1, 'minutes').humanize(true)).toBe('dans une minute') dayjs.locale('es') expect(dayjs.duration(1, 'minutes').humanize(true)).toBe('en un minuto') dayjs.locale('en') }) }) describe('Clone', () => { it('Locale clone', () => { const d = dayjs.duration(1, 'minutes').locale('fr') const r = 'dans une minute' expect(d.humanize(true)).toBe(r) expect(d.clone().humanize(true)).toBe(r) }) }) describe('Milliseconds', () => { expect(dayjs.duration(500).milliseconds()).toBe(500) expect(dayjs.duration(1500).milliseconds()).toBe(500) expect(dayjs.duration(15000).milliseconds()).toBe(0) expect(dayjs.duration(500).asMilliseconds()).toBe(500) expect(dayjs.duration(1500).asMilliseconds()).toBe(1500) expect(dayjs.duration(15000).asMilliseconds()).toBe(15000) }) describe('Milliseconds', () => { describe('Positive number', () => { expect(dayjs.duration(500).milliseconds()).toBe(500) expect(dayjs.duration(1500).milliseconds()).toBe(500) expect(dayjs.duration(15000).milliseconds()).toBe(0) expect(dayjs.duration(500).asMilliseconds()).toBe(500) expect(dayjs.duration(1500).asMilliseconds()).toBe(1500) expect(dayjs.duration(15000).asMilliseconds()).toBe(15000) }) describe('Negative number', () => { expect(dayjs.duration(-500).milliseconds()).toBe(-500) expect(dayjs.duration(-1500).milliseconds()).toBe(-500) expect(dayjs.duration(-15000).milliseconds()).toBe(0) expect(dayjs.duration(-500).asMilliseconds()).toBe(-500) expect(dayjs.duration(-1500).asMilliseconds()).toBe(-1500) expect(dayjs.duration(-15000).asMilliseconds()).toBe(-15000) }) }) describe('Add', () => { const a = dayjs.duration(1, 'days') const b = dayjs.duration(2, 'days') expect(a.add(b).days()).toBe(3) expect(a.add(1, 'days').days()).toBe(2) expect(a.add({ days: 5 }).days()).toBe(6) }) describe('Add to a dayjs()', () => { const a = dayjs() const b = dayjs.duration({ hours: 7, minutes: 10 }) expect(a.add(b)).toEqual(a.add(7, 'hours').add(10, 'minutes')) }) test('Add duration', () => { const a = dayjs('2020-10-01') const days = dayjs.duration(2, 'days') expect(a.add(days).format('YYYY-MM-DD')).toBe('2020-10-03') const b = dayjs('2023-02-01 00:00:00') const p = dayjs.duration('P1Y1M1DT1H1M1S') expect(b.add(p).format('YYYY-MM-DD HH:mm:ss')).toBe('2024-03-02 01:01:01') }) describe('Subtract', () => { const a = dayjs.duration(3, 'days') const b = dayjs.duration(2, 'days') expect(a.subtract(b).days()).toBe(1) }) test('Subtract duration', () => { const a = dayjs('2020-10-20') const days = dayjs.duration(2, 'days') expect(a.subtract(days).format('YYYY-MM-DD')).toBe('2020-10-18') const b = dayjs('2023-03-02 02:02:02') const p = dayjs.duration('P1Y1M1DT1H1M1S') expect(b.subtract(p).format('YYYY-MM-DD HH:mm:ss')).toBe('2022-02-01 01:01:01') }) describe('Seconds', () => { expect(dayjs.duration(500).seconds()).toBe(0) expect(dayjs.duration(1500).seconds()).toBe(1) expect(dayjs.duration(15000).seconds()).toBe(15) expect(dayjs.duration(61000).seconds()).toBe(1) // 1 minute 1 second expect(dayjs.duration(500).asSeconds()).toBe(0.5) expect(dayjs.duration(1500).asSeconds()).toBe(1.5) expect(dayjs.duration(15000).asSeconds()).toBe(15) }) describe('Minutes', () => { expect(dayjs.duration(100000).minutes()).toBe(1) expect(dayjs.duration(61000).minutes()).toBe(1) // 1 minute 1 second expect(dayjs.duration(100000).asMinutes().toFixed(2)).toBe('1.67') }) describe('Hours', () => { expect(dayjs.duration(10000000).hours()).toBe(2) expect(dayjs.duration(10000000).asHours().toFixed(2)).toBe('2.78') }) describe('Days', () => { it('positive number', () => { expect(dayjs.duration(100000000).days()).toBe(1) expect(dayjs.duration(100000000).asDays().toFixed(2)).toBe('1.16') }) it('negative number', () => { expect(dayjs.duration(-1).days()).toBe(0) expect(dayjs.duration(-86399999).asDays()).toBeCloseTo(-0.999999, 4) }) }) describe('Weeks', () => { expect(dayjs.duration(1000000000).weeks()).toBe(1) expect(dayjs.duration(1000000000).asWeeks().toFixed(2)).toBe('1.65') }) describe('Month', () => { expect(dayjs.duration(10000000000).months()).toBe(3) expect(dayjs.duration({ months: 3 }).asMonths()).toBe(3) }) describe('Years', () => { expect(dayjs.duration(100000000000).years()).toBe(3) expect(dayjs.duration(100000000000).asYears().toFixed(2)).toBe('3.17') }) describe('prettyUnit', () => { const d = dayjs.duration(2, 's') expect(d.toISOString()).toBe('PT2S') expect(d.as('seconds')).toBe(2) expect(d.get('s')).toBe(2) expect(dayjs.duration({ M: 12, m: 12 }).toISOString()).toBe('P12MT12M') }) describe('Format', () => { test('no formatStr', () => { const d = dayjs.duration(15, 'seconds') .add(13, 'hours') .add(35, 'minutes') .add(16, 'days') .add(10, 'months') .add(22, 'years') expect(d.format()).toBe('0022-10-16T13:35:15') }) test('with formatStr for all tokens', () => { const d = dayjs.duration(1, 'seconds') .add(8, 'hours') .add(5, 'minutes') .add(6, 'days') .add(9, 'months') .add(2, 'years') .add(10, 'milliseconds') expect(d.format('Y/YY.YYYYTESTM:MM:D:DD:H:HH:m:mm:s:ss:SSS')) .toBe('2/02.0002TEST9:09:6:06:8:08:5:05:1:01:010') }) test('formats YYY as YY + Y', () => { const d = dayjs.duration(2, 'years') expect(d.format('YYY')).toBe('022') }) }) ================================================ FILE: test/plugin/isBetween.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src/index' import isBetween from '../../src/plugin/isBetween/index' dayjs.extend(isBetween) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) test('bounds can be swapped', () => { expect(dayjs('2018-01-01').isBetween(dayjs('2017-12-31'), dayjs('2018-01-02'))).toBeTruthy() expect(dayjs('2018-01-01').isBetween(dayjs('2018-01-02'), dayjs('2017-12-31'))).toBeTruthy() }) test('bounds can be swapped with inclusivity', () => { expect(dayjs('2018-01-01').isBetween(dayjs('2017-12-31'), dayjs('2018-01-01'), null, '[]')).toBeTruthy() expect(dayjs('2018-01-01').isBetween(dayjs('2018-01-01'), dayjs('2017-12-31'), null, '[]')).toBeTruthy() }) test('is between without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'year is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2013, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'year is earlier') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)) )).toBe(true, 'year is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'month is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 5, 2, 3, 4, 5, 10)) )).toBe(false, 'month is earlier') expect(m.isBetween( dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)) )).toBe(true, 'month is between') expect(m.isBetween( dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'day is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 4, 3, 4, 5, 10)) )).toBe(false, 'day is earlier') expect(m.isBetween( dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)) )).toBe(true, 'day is between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 1, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'hour is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 5, 4, 5, 10)) )).toBe(false, 'hour is earlier') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)) )).toBe(true, 'hour is between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 6, 5, 10)) )).toBe(false, 'minute is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 2, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'minute is earlier') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)) )).toBe(true, 'minute is between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 7, 10)) )).toBe(false, 'second is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 3, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'second is earlier') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 4, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)) )).toBe(true, 'second is between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 12)) )).toBe(false, 'millisecond is later') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 8)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) )).toBe(false, 'millisecond is earlier') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)) )).toBe(true, 'millisecond is between') expect(m.isBetween(m, m)).toBe(false, 'moments are not between themselves') expect(+m).toEqual(+mCopy, 'isBetween second should not change moment') }) test('is between year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year' )).toBe(false, 'year match') expect(m.isBetween( dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years' )).toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year' )).toBe(true, 'year is between') expect(m.isBetween( dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), dayjs(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year' )).toBe(false, 'year is earlier') expect(m.isBetween( dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year' )).toBe(false, 'year is later') expect(m.isBetween(m, 'year')).toBe(false, 'same moments are not between the same year') expect(+m).toEqual(+mCopy, 'isBetween year should not change moment') }) test('is between month', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month' )).toBe(false, 'month match') expect(m.isBetween( dayjs(new Date(2011, 0, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months' )).toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 0, 31, 23, 59, 59, 999)), dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month' )).toBe(true, 'month is between') expect(m.isBetween( dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month' )).toBe(false, 'month is earlier') expect(m.isBetween( dayjs(new Date(2011, 11, 6, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month' )).toBe(false, 'month is later') expect(m.isBetween(m, 'month')).toBe(false, 'same moments are not between the same month') expect(+m).toEqual(+mCopy, 'isBetween month should not change moment') }) test('is between day', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day' )).toBe(false, 'day match') expect(m.isBetween( dayjs(new Date(2011, 1, 1, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 3, 7, 8, 9, 10)), 'days' )).toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 1, 1, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day' )).toBe(true, 'day is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 4, 7, 8, 9, 10)), 'day' )).toBe(false, 'day is earlier') expect(m.isBetween( dayjs(new Date(2011, 1, 1, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day' )).toBe(false, 'day is later') expect(m.isBetween(m, 'day')).toBe(false, 'same moments are not between the same day') expect(+m).toEqual(+mCopy, 'isBetween day should not change moment') }) test('is between hour', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 5, 9, 10)), dayjs(new Date(2011, 1, 2, 3, 9, 9, 10)), 'hour' )) .toBe(false, 'hour match') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 1, 59, 59, 999)), dayjs(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hours' )) .toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 2, 59, 59, 999)), dayjs(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour' )) .toBe(true, 'hour is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour' )) .toBe(false, 'hour is earlier') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour' )) .toBe(false, 'hour is later') expect(m.isBetween(m, 'hour')) .toBe(false, 'same moments are not between the same hour') expect(+m) .toEqual(+mCopy, 'isBetween hour should not change moment') }) test('is between minute', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute' )) .toBe(false, 'minute match') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 3, 9, 10)), dayjs(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minutes' )) .toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 3, 59, 999)), dayjs(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute' )) .toBe(true, 'minute is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 5, 0, 0)), dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'minute' )) .toBe(false, 'minute is earlier') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 2, 9, 10)), dayjs(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute' )) .toBe(false, 'minute is later') expect(m.isBetween(m, 'minute')) .toBe(false, 'same moments are not between the same minute') expect(+m) .toEqual(+mCopy, 'isBetween minute should not change moment') }) test('is between second', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second' )) .toBe(false, 'second match') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 4, 10)), dayjs(new Date(2011, 1, 2, 3, 4, 6, 10)), 'seconds' )) .toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 4, 999)), dayjs(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second' )) .toBe(true, 'second is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 6, 0)), dayjs(new Date(2011, 1, 2, 3, 4, 7, 10)), 'second' )) .toBe(false, 'second is earlier') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 3, 10)), dayjs(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second' )) .toBe(false, 'second is later') expect(m.isBetween(m, 'second')).toBe(false, 'same moments are not between the same second') expect(+m).toEqual(+mCopy, 'isBetween second should not change moment') }) test('is between millisecond', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond' )).toBe(false, 'millisecond match') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 5)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 7)), 'milliseconds' )).toBe(true, 'plural should work') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 5)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 7)), 'millisecond' )).toBe(true, 'millisecond is between') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 7)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'millisecond' )).toBe(false, 'millisecond is earlier') expect(m.isBetween( dayjs(new Date(2011, 1, 2, 3, 4, 5, 4)), dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond' )).toBe(false, 'millisecond is later') expect(m.isBetween(m, 'millisecond')).toBe(false, 'same moments are not between the same millisecond') expect(+m).toEqual(+mCopy, 'isBetween millisecond should not change moment') }) test('is between without units inclusivity', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()' )).toBe(false, 'start and end are excluded, start is equal to dayjs') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()' )).toBe(false, 'start and end are excluded, end is equal to dayjs') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()' )).toBe(true, 'start and end are excluded, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '()' )).toBe(false, 'start and end are excluded, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()' )).toBe(false, 'start and end are excluded, should fail on same start/end date.') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]' )).toBe(false, 'start is excluded and end is included should fail on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]' )).toBe(true, 'start is excluded and end is included should succeed on end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]' )).toBe(true, 'start is excluded and end is included, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '(]' )).toBe(false, 'start is excluded and end is included, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]' )).toBe(false, 'start is excluded and end is included, should fail on same start/end date.') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)' )).toBe(true, 'start is included and end is excluded should succeed on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)' )).toBe(false, 'start is included and end is excluded should fail on same end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)' )).toBe(true, 'start is included and end is excluded, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[)' )).toBe(false, 'start is included and end is excluded, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)' )).toBe(false, 'start is included and end is excluded, should fail on same end and start date') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]' )).toBe(true, 'start and end inclusive should succeed on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]' )).toBe(true, 'start and end inclusive should succeed on same end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]' )).toBe(true, 'start and end inclusive, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[]' )).toBe(false, 'start and end inclusive, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]' )).toBe(true, 'start and end inclusive, should handle same end and start date') expect(+m).toEqual(+mCopy, 'isBetween millisecond should not change moment') }) test('is between milliseconds inclusivity', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds' )).toBe(true, 'options, no inclusive') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()' )).toBe(false, 'start and end are excluded, start is equal to dayjs') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()' )).toBe(false, 'start and end are excluded, end is equal to dayjs') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()' )).toBe(true, 'start and end are excluded, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()' )).toBe(false, 'start and end are excluded, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()' )).toBe(false, 'start and end are excluded, should fail on same start/end date.') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]' )).toBe(false, 'start is excluded and end is included should fail on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]' )).toBe(true, 'start is excluded and end is included should succeed on end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]' )).toBe(true, 'start is excluded and end is included, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]' )).toBe(false, 'start is excluded and end is included, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]' )).toBe(false, 'start is excluded and end is included, should fail on same start/end date.') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)' )).toBe(true, 'start is included and end is excluded should succeed on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)' )).toBe(false, 'start is included and end is excluded should fail on same end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)' )).toBe(true, 'start is included and end is excluded, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)' )).toBe(false, 'start is included and end is excluded, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)' )).toBe(false, 'start is included and end is excluded, should fail on same end and start date') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]' )).toBe(true, 'start and end inclusive should succeed on same start date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]' )).toBe(true, 'start and end inclusive should succeed on same end date') expect(m.isBetween( dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]' )).toBe(true, 'start and end inclusive, is between') expect(m.isBetween( dayjs(new Date(2009, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]' )).toBe(false, 'start and end inclusive, is not between') expect(m.isBetween( dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]' )).toBe(true, 'start and end inclusive, should handle same end and start date') expect(+m).toEqual(+mCopy, 'isBetween second should not change moment') }) ================================================ FILE: test/plugin/isLeapYear.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isLeapYear from '../../src/plugin/isLeapYear' dayjs.extend(isLeapYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('IsLeapYear', () => { expect(dayjs('20000101').isLeapYear()).toBe(true) expect(dayjs('2100-01-01').isLeapYear()).toBe(false) }) ================================================ FILE: test/plugin/isMoment.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isMoment from '../../src/plugin/isMoment' dayjs.extend(isMoment) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('IsLeapYear', () => { expect(dayjs.isMoment(dayjs())).toBe(true) expect(dayjs.isMoment(new Date())).toBe(false) }) ================================================ FILE: test/plugin/isSameOrAfter.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isSameOrAfter from '../../src/plugin/isSameOrAfter' dayjs.extend(isSameOrAfter) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) test('is same or after year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year match') expect(m.isSameOrAfter(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year')).toBe(true, 'exact start of year') expect(m.isSameOrAfter(dayjs(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'exact end of year') expect(m.isSameOrAfter(dayjs(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year')).toBe(false, 'start of next year') expect(m.isSameOrAfter(dayjs(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'end of previous year') expect(m.isSameOrAfter(m, 'year')).toBe(true, 'same moments are in the same year') expect(+m).toEqual(+mCopy, 'isSameOrAfter year should not change moment') }) test('is same or after without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2012, 3, 2, 3, 5, 5, 10)))).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 3, 2, 3, 3, 5, 10)))).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)))).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)))).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)))).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)))).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)))).toBe(false, 'hour is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)))).toBe(true, 'hour is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)))).toBe(false, 'minute is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)))).toBe(true, 'minute is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)))).toBe(false, 'second is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 11)))).toBe(true, 'second is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)))).toBe(true, 'millisecond match') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)))).toBe(false, 'millisecond is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)))).toBe(true, 'millisecond is earlier') expect(m.isSameOrAfter(m)).toBe(true, 'moments are the same as themselves') expect(+m).toEqual(+mCopy, 'isSameOrAfter second should not change moment') }) test('is same or after without date', () => { const past = dayjs().subtract(1, 'day') const future = dayjs().add(1, 'day') expect(past.isSameOrAfter()).toBe(false, 'past is before now') expect(future.isSameOrAfter()).toBe(true, 'future is not before now') }) test('is same or after month', () => { const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month match') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month')).toBe(true, 'exact start of month') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month')).toBe(true, 'exact end of month') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month')).toBe(false, 'start of next month') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month')).toBe(true, 'end of previous month') expect(m.isSameOrAfter(m, 'month')).toBe(true, 'same moments are in the same month') expect(+m).toEqual(+mCopy, 'isSameOrAfter month should not change moment') }) test('is same or after day', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'day match') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 1, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 12, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day')).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 1, 7, 8, 9, 10)), 'day')).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day')).toBe(true, 'exact start of day') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day')).toBe(true, 'exact end of day') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day')).toBe(false, 'start of next day') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day')).toBe(true, 'end of previous day') expect(m.isSameOrAfter(m, 'day')).toBe(true, 'same moments are in the same day') expect(+m).toEqual(+mCopy, 'isSameOrAfter day should not change moment') }) test('is same or after hour', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'hour match') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 12, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour')).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 1, 3, 8, 9, 10)), 'hour')).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour')).toBe(false, 'hour is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 2, 8, 9, 10)), 'hour')).toBe(true, 'hour is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour')).toBe(true, 'exact start of hour') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour')).toBe(true, 'exact end of hour') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour')).toBe(false, 'start of next hour') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour')).toBe(true, 'end of previous hour') expect(m.isSameOrAfter(m, 'hour')).toBe(true, 'same moments are in the same hour') expect(+m).toEqual(+mCopy, 'isSameOrAfter hour should not change moment') }) test('is same or after minute', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'minute match') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 12, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute')).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 1, 3, 4, 9, 10)), 'minute')).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute')).toBe(false, 'hour is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 2, 4, 9, 10)), 'minute')).toBe(true, 'hour is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute')).toBe(false, 'minute is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 3, 9, 10)), 'minute')).toBe(true, 'minute is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute')).toBe(true, 'exact start of minute') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute')).toBe(true, 'exact end of minute') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute')).toBe(false, 'start of next minute') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute')).toBe(true, 'end of previous minute') expect(m.isSameOrAfter(m, 'minute')).toBe(true, 'same moments are in the same minute') expect(+m).toEqual(+mCopy, 'isSameOrAfter minute should not change moment') }) test('is same or after second', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'second match') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 1, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 12, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second')).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 1, 3, 4, 5, 10)), 'second')).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second')).toBe(false, 'hour is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 2, 4, 5, 10)), 'second')).toBe(true, 'hour is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second')).toBe(false, 'minute is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 3, 5, 10)), 'second')).toBe(true, 'minute is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second')).toBe(false, 'second is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 4, 10)), 'second')).toBe(true, 'second is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second')).toBe(true, 'exact start of second') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second')).toBe(true, 'exact end of second') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second')).toBe(false, 'start of next second') expect(m.isSameOrAfter(dayjs(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second')).toBe(true, 'end of previous second') expect(m.isSameOrAfter(m, 'second')).toBe(true, 'same moments are in the same second') expect(+m).toEqual(+mCopy, 'isSameOrAfter second should not change moment') }) test('is same or after millisecond', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'millisecond match') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds')).toBe(true, 'plural should work') expect(m.isSameOrAfter(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is later') expect(m.isSameOrAfter(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'year is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'month is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'day is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond')).toBe(true, 'day is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond')).toBe(false, 'hour is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond')).toBe(true, 'hour is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond')).toBe(false, 'minute is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond')).toBe(true, 'minute is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond')).toBe(false, 'second is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond')).toBe(true, 'second is earlier') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond')).toBe(false, 'millisecond is later') expect(m.isSameOrAfter(dayjs(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond')).toBe(true, 'millisecond is earlier') expect(m.isSameOrAfter(m, 'millisecond')).toBe(true, 'same moments are in the same millisecond') expect(+m).toEqual(+mCopy, 'isSameOrAfter millisecond should not change moment') }) test('is same or after with invalid moments', () => { const m = dayjs() const invalid = dayjs(null) expect(invalid.isSameOrAfter(invalid)).toBe(false, 'invalid moments are not considered equal') expect(m.isSameOrAfter(invalid)).toBe(false, 'valid moment is not after invalid moment') expect(invalid.isSameOrAfter(m)).toBe(false, 'invalid moment is not after valid moment') expect(m.isSameOrAfter(invalid, 'year')).toBe(false, 'invalid moment year') expect(m.isSameOrAfter(invalid, 'month')).toBe(false, 'invalid moment month') expect(m.isSameOrAfter(invalid, 'day')).toBe(false, 'invalid moment day') expect(m.isSameOrAfter(invalid, 'hour')).toBe(false, 'invalid moment hour') expect(m.isSameOrAfter(invalid, 'minute')).toBe(false, 'invalid moment minute') expect(m.isSameOrAfter(invalid, 'second')).toBe(false, 'invalid moment second') expect(m.isSameOrAfter(invalid, 'milliseconds')).toBe(false, 'invalid moment milliseconds') }) ================================================ FILE: test/plugin/isSameOrBefore.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isSameOrBefore from '../../src/plugin/isSameOrBefore' dayjs.extend(isSameOrBefore) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) test('is same or before without units', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2012, 3, 2, 3, 5, 5, 10)))).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 3, 2, 3, 3, 5, 10)))).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)))).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)))).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)))).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 1, 3, 4, 5, 10)))).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)))).toBe(true, 'hour is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 2, 4, 5, 10)))).toBe(false, 'hour is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)))).toBe(true, 'minute is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)))).toBe(false, 'minute is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)))).toBe(true, 'second is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 11)))).toBe(false, 'second is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)))).toBe(true, 'millisecond match') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 11)))).toBe(true, 'millisecond is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 9)))).toBe(false, 'millisecond is earlier') expect(m.isSameOrBefore(m)).toBe(true, 'moments are the same as themselves') expect(+m).toEqual(+mCopy, 'isSameOrBefore second should not change moment') }) test('is same or before without date', () => { const past = dayjs().subtract(1, 'day') const future = dayjs().add(1, 'day') expect(past.isSameOrBefore()).toBe(true, 'past is before now') expect(future.isSameOrBefore()).toBe(false, 'future is not before now') }) test('is same or before year', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year match') expect(m.isSameOrBefore(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year')).toBe(true, 'exact start of year') expect(m.isSameOrBefore(dayjs(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year')).toBe(true, 'exact end of year') expect(m.isSameOrBefore(dayjs(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year')).toBe(true, 'start of next year') expect(m.isSameOrBefore(dayjs(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year')).toBe(false, 'end of previous year') expect(m.isSameOrBefore(m, 'year')).toBe(true, 'same moments are in the same year') expect(+m).toEqual(+mCopy, 'isSameOrBefore year should not change moment') }) test('is same or before month', () => { const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month match') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month')).toBe(true, 'exact start of month') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month')).toBe(true, 'exact end of month') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month')).toBe(true, 'start of next month') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month')).toBe(false, 'end of previous month') expect(m.isSameOrBefore(m, 'month')).toBe(true, 'same moments are in the same month') expect(+m).toEqual(+mCopy, 'isSameOrBefore month should not change moment') }) test('is same or before day', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'day match') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 1, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 12, 2, 7, 8, 9, 10)), 'day')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day')).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 1, 7, 8, 9, 10)), 'day')).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day')).toBe(true, 'exact start of day') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day')).toBe(true, 'exact end of day') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day')).toBe(true, 'start of next day') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day')).toBe(false, 'end of previous day') expect(m.isSameOrBefore(m, 'day')).toBe(true, 'same moments are in the same day') expect(+m).toEqual(+mCopy, 'isSameOrBefore day should not change moment') }) test('is same or before hour', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'hour match') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 1, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 12, 2, 3, 8, 9, 10)), 'hour')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour')).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 1, 3, 8, 9, 10)), 'hour')).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour')).toBe(true, 'hour is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 2, 8, 9, 10)), 'hour')).toBe(false, 'hour is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour')).toBe(true, 'exact start of hour') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour')).toBe(true, 'exact end of hour') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour')).toBe(true, 'start of next hour') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour')).toBe(false, 'end of previous hour') expect(m.isSameOrBefore(m, 'hour')).toBe(true, 'same moments are in the same hour') expect(+m).toEqual(+mCopy, 'isSameOrBefore hour should not change moment') }) test('is same or before minute', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'minute match') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 1, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 12, 2, 3, 4, 9, 10)), 'minute')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute')).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 1, 3, 4, 9, 10)), 'minute')).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute')).toBe(true, 'hour is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 2, 4, 9, 10)), 'minute')).toBe(false, 'hour is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute')).toBe(true, 'minute is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 3, 9, 10)), 'minute')).toBe(false, 'minute is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute')).toBe(true, 'exact start of minute') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute')).toBe(true, 'exact end of minute') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute')).toBe(true, 'start of next minute') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute')).toBe(false, 'end of previous minute') expect(m.isSameOrBefore(m, 'minute')).toBe(true, 'same moments are in the same minute') expect(+m).toEqual(+mCopy, 'isSameOrBefore minute should not change moment') }) test('is same or before second', () => { const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'second match') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 1, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 12, 2, 3, 4, 5, 10)), 'second')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second')).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 1, 3, 4, 5, 10)), 'second')).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second')).toBe(true, 'hour is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 2, 4, 5, 10)), 'second')).toBe(false, 'hour is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second')).toBe(true, 'minute is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 3, 5, 10)), 'second')).toBe(false, 'minute is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second')).toBe(true, 'second is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 4, 10)), 'second')).toBe(false, 'second is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second')).toBe(true, 'exact start of second') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second')).toBe(true, 'exact end of second') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second')).toBe(true, 'start of next second') expect(m.isSameOrBefore(dayjs(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second')).toBe(false, 'end of previous second') expect(m.isSameOrBefore(m, 'second')).toBe(true, 'same moments are in the same second') expect(+m).toEqual(+mCopy, 'isSameOrBefore second should not change moment') }) test('is same or before millisecond', () => { const m = dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)) const mCopy = dayjs(m) expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'millisecond match') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds')).toBe(true, 'plural should work') expect(m.isSameOrBefore(dayjs(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'year is later') expect(m.isSameOrBefore(dayjs(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'year is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'month is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond')).toBe(false, 'month is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond')).toBe(true, 'day is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond')).toBe(false, 'day is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond')).toBe(true, 'hour is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond')).toBe(false, 'hour is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond')).toBe(true, 'minute is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond')).toBe(false, 'minute is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond')).toBe(true, 'second is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond')).toBe(false, 'second is earlier') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond')).toBe(true, 'millisecond is later') expect(m.isSameOrBefore(dayjs(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond')).toBe(false, 'millisecond is earlier') expect(m.isSameOrBefore(m, 'millisecond')).toBe(true, 'same moments are in the same millisecond') expect(+m).toEqual(+mCopy, 'isSameOrBefore millisecond should not change moment') }) test('is same with invalid moments', () => { const m = dayjs() const invalid = dayjs(null) expect(invalid.isSameOrBefore(invalid)).toBe(false, 'invalid moments are not considered equal') expect(m.isSameOrBefore(invalid)).toBe(false, 'valid moment is not before invalid moment') expect(invalid.isSameOrBefore(m)).toBe(false, 'invalid moment is not before valid moment') expect(m.isSameOrBefore(invalid, 'year')).toBe(false, 'invalid moment year') expect(m.isSameOrBefore(invalid, 'month')).toBe(false, 'invalid moment month') expect(m.isSameOrBefore(invalid, 'day')).toBe(false, 'invalid moment day') expect(m.isSameOrBefore(invalid, 'hour')).toBe(false, 'invalid moment hour') expect(m.isSameOrBefore(invalid, 'minute')).toBe(false, 'invalid moment minute') expect(m.isSameOrBefore(invalid, 'second')).toBe(false, 'invalid moment second') expect(m.isSameOrBefore(invalid, 'milliseconds')).toBe(false, 'invalid moment milliseconds') }) ================================================ FILE: test/plugin/isToday.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isToday from '../../src/plugin/isToday' dayjs.extend(isToday) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('is today', () => { expect(dayjs(new Date()).isToday()).toBeTruthy() expect(dayjs('2017-01-01').isToday()).toBeFalsy() }) ================================================ FILE: test/plugin/isTomorrow.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isTomorrow from '../../src/plugin/isTomorrow' dayjs.extend(isTomorrow) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('is tomorrow', () => { expect(dayjs().add(1, 'day').isTomorrow()).toBeTruthy() expect(dayjs('2017-01-01').isTomorrow('2019-01-01', '2017-01-01')).toBeFalsy() }) ================================================ FILE: test/plugin/isYesterday.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isYesterday from '../../src/plugin/isYesterday' dayjs.extend(isYesterday) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('is yesterday', () => { expect(dayjs().subtract(1, 'day').isYesterday()).toBeTruthy() expect(dayjs('2017-01-01').isYesterday()).toBeFalsy() }) ================================================ FILE: test/plugin/isoWeek.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import isoWeek from '../../src/plugin/isoWeek' import utc from '../../src/plugin/utc' dayjs.extend(isoWeek) dayjs.extend(utc) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('get isoWeek', () => { expect(dayjs().isoWeek()).toBe(moment().isoWeek()) }) it('set isoWeek', () => { expect(dayjs().isoWeek(1).valueOf()).toBe(moment().isoWeek(1).valueOf()) expect(dayjs().isoWeek(52).valueOf()).toBe(moment().isoWeek(52).valueOf()) }) it('get isoWeekYear', () => { expect(dayjs().isoWeekYear()).toBe(moment().isoWeekYear()) }) it('startOf/endOf isoWeek', () => { const ISOWEEK = 'isoWeek' expect(dayjs().startOf(ISOWEEK).valueOf()).toBe(moment().startOf(ISOWEEK).valueOf()) expect(dayjs().endOf(ISOWEEK).valueOf()).toBe(moment().endOf(ISOWEEK).valueOf()) }) it('isoWeekday', () => { expect(dayjs().isoWeekday()).toBe(moment().isoWeekday()) expect(dayjs('20200301').isoWeekday(1).valueOf()).toBe(moment('20200301').isoWeekday(1).valueOf()) // Sunday this.day() -> 0 for (let i = 0; i < 7; i += 1) { expect(dayjs().add(i, 'day').isoWeekday()).toBe(moment().add(i, 'day').isoWeekday()) expect(dayjs().isoWeekday(i).valueOf()).toBe(moment().isoWeekday(i).valueOf()) expect(dayjs().add(1, 'day').isoWeekday(i).valueOf()).toBe(moment().add(1, 'day').isoWeekday(i).valueOf()) } }) it('isoWeek of year', () => { expect(dayjs().isoWeek(1).isoWeek()).toBe(1) expect(dayjs().isoWeek(27).isoWeek()).toBe(27) expect(dayjs('20191223').isoWeekYear()).toBe(2019) expect(dayjs('20191223').isoWeek()).toBe(52) expect(dayjs('20191224').isoWeekYear()).toBe(2019) expect(dayjs('20191224').isoWeek()).toBe(52) expect(dayjs('20191225').isoWeekYear()).toBe(2019) expect(dayjs('20191225').isoWeek()).toBe(52) expect(dayjs('20191226').isoWeekYear()).toBe(2019) expect(dayjs('20191226').isoWeek()).toBe(52) expect(dayjs('20191227').isoWeekYear()).toBe(2019) expect(dayjs('20191227').isoWeek()).toBe(52) expect(dayjs('20191228').isoWeekYear()).toBe(2019) expect(dayjs('20191228').isoWeek()).toBe(52) expect(dayjs('20191229').isoWeekYear()).toBe(2019) expect(dayjs('20191229').isoWeek()).toBe(52) expect(dayjs('20191230').isoWeekYear()).toBe(2020) expect(dayjs('20191230').isoWeek()).toBe(1) expect(dayjs('20191231').isoWeekYear()).toBe(2020) expect(dayjs('20191231').isoWeek()).toBe(1) expect(dayjs('20200101').isoWeekYear()).toBe(2020) expect(dayjs('20200101').isoWeek()).toBe(1) expect(dayjs('20200102').isoWeekYear()).toBe(2020) expect(dayjs('20200102').isoWeek()).toBe(1) expect(dayjs('20200103').isoWeekYear()).toBe(2020) expect(dayjs('20200103').isoWeek()).toBe(1) expect(dayjs('20200104').isoWeekYear()).toBe(2020) expect(dayjs('20200104').isoWeek()).toBe(1) expect(dayjs('20200105').isoWeekYear()).toBe(2020) expect(dayjs('20200105').isoWeek()).toBe(1) expect(dayjs('20200106').isoWeekYear()).toBe(2020) expect(dayjs('20200106').isoWeek()).toBe(2) expect(dayjs('20200107').isoWeekYear()).toBe(2020) expect(dayjs('20200107').isoWeek()).toBe(2) expect(dayjs('20201223').isoWeekYear()).toBe(2020) expect(dayjs('20201223').isoWeek()).toBe(52) expect(dayjs('20201224').isoWeekYear()).toBe(2020) expect(dayjs('20201224').isoWeek()).toBe(52) expect(dayjs('20201225').isoWeekYear()).toBe(2020) expect(dayjs('20201225').isoWeek()).toBe(52) expect(dayjs('20201226').isoWeekYear()).toBe(2020) expect(dayjs('20201226').isoWeek()).toBe(52) expect(dayjs('20201227').isoWeekYear()).toBe(2020) expect(dayjs('20201227').isoWeek()).toBe(52) expect(dayjs('20201228').isoWeekYear()).toBe(2020) expect(dayjs('20201228').isoWeek()).toBe(53) expect(dayjs('20201229').isoWeekYear()).toBe(2020) expect(dayjs('20201229').isoWeek()).toBe(53) expect(dayjs('20201230').isoWeekYear()).toBe(2020) expect(dayjs('20201230').isoWeek()).toBe(53) expect(dayjs('20201231').isoWeekYear()).toBe(2020) expect(dayjs('20201231').isoWeek()).toBe(53) expect(dayjs('20210101').isoWeekYear()).toBe(2020) expect(dayjs('20210101').isoWeek()).toBe(53) expect(dayjs('20210102').isoWeekYear()).toBe(2020) expect(dayjs('20210102').isoWeek()).toBe(53) expect(dayjs('20210103').isoWeekYear()).toBe(2020) expect(dayjs('20210103').isoWeek()).toBe(53) expect(dayjs('20210104').isoWeekYear()).toBe(2021) expect(dayjs('20210104').isoWeek()).toBe(1) expect(dayjs('20210105').isoWeekYear()).toBe(2021) expect(dayjs('20210105').isoWeek()).toBe(1) expect(dayjs('20210106').isoWeekYear()).toBe(2021) expect(dayjs('20210106').isoWeek()).toBe(1) expect(dayjs('20210107').isoWeekYear()).toBe(2021) expect(dayjs('20210107').isoWeek()).toBe(1) expect(dayjs('20210108').isoWeekYear()).toBe(2021) expect(dayjs('20210108').isoWeek()).toBe(1) expect(dayjs('20210109').isoWeekYear()).toBe(2021) expect(dayjs('20210109').isoWeek()).toBe(1) expect(dayjs('20210110').isoWeekYear()).toBe(2021) expect(dayjs('20210110').isoWeek()).toBe(1) }) it('utc mode', () => { // Wednesday, 1 January 2020 00:00:00 UTC const d = dayjs.utc(1577836800000).isoWeek() expect(d).toBe(1) expect(moment.utc(1577836800000).isoWeek()).toBe(d) }) ================================================ FILE: test/plugin/isoWeeksInYear.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import isoWeeksInYear from '../../src/plugin/isoWeeksInYear' import isLeapYear from '../../src/plugin/isLeapYear' dayjs.extend(isoWeeksInYear) dayjs.extend(isLeapYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('isoWeeksInYear', () => { expect(dayjs('2004').isoWeeksInYear()).toBe(53) expect(dayjs('2005').isoWeeksInYear()).toBe(52) expect(dayjs('2006').isoWeeksInYear()).toBe(52) expect(dayjs('2007').isoWeeksInYear()).toBe(52) expect(dayjs('2008').isoWeeksInYear()).toBe(52) expect(dayjs('2009').isoWeeksInYear()).toBe(53) expect(dayjs('2010').isoWeeksInYear()).toBe(52) expect(dayjs('2011').isoWeeksInYear()).toBe(52) expect(dayjs('2012').isoWeeksInYear()).toBe(52) expect(dayjs('2013').isoWeeksInYear()).toBe(52) expect(dayjs('2014').isoWeeksInYear()).toBe(52) expect(dayjs('2015').isoWeeksInYear()).toBe(53) }) ================================================ FILE: test/plugin/localeData.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import '../../src/locale/fr' import '../../src/locale/ru' import '../../src/locale/zh-cn' import localeData from '../../src/plugin/localeData' import localizedFormat from '../../src/plugin/localizedFormat' dayjs.extend(localizedFormat) dayjs.extend(localeData) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('Instance localeData', () => { ['zh-cn', 'en', 'fr'].forEach((lo) => { it(`Locale: ${lo}`, () => { dayjs.locale(lo) moment.locale(lo) const d = dayjs() const m = moment() const dayjsLocaleData = dayjs().localeData() const momentLocaleData = moment().localeData() expect(dayjsLocaleData.firstDayOfWeek()).toBe(momentLocaleData.firstDayOfWeek()) expect(dayjsLocaleData.months(d)).toBe(momentLocaleData.months(m)) expect(dayjsLocaleData.months()).toEqual(momentLocaleData.months()) expect(dayjsLocaleData.monthsShort(d)).toBe(momentLocaleData.monthsShort(m)) expect(dayjsLocaleData.monthsShort()).toEqual(momentLocaleData.monthsShort()) expect(dayjsLocaleData.weekdays(d)).toBe(momentLocaleData.weekdays(m)) expect(dayjsLocaleData.weekdays()).toEqual(momentLocaleData.weekdays()) expect(dayjsLocaleData.weekdaysMin(d)).toBe(momentLocaleData.weekdaysMin(m)) expect(dayjsLocaleData.weekdaysMin()).toEqual(momentLocaleData.weekdaysMin()) expect(dayjsLocaleData.weekdaysShort(d)).toBe(momentLocaleData.weekdaysShort(m)) expect(dayjsLocaleData.weekdaysShort()).toEqual(momentLocaleData.weekdaysShort()) const longDateFormats = ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL', 'l', 'll', 'lll', 'llll'] longDateFormats.forEach((f) => { expect(dayjsLocaleData.longDateFormat(f)).toEqual(momentLocaleData.longDateFormat(f)) }) }) }) dayjs.locale('en') moment.locale('en') }) it('Global localeData', () => { ['zh-cn', 'en', 'fr'].forEach((lo) => { dayjs.locale(lo) moment.locale(lo) const dayjsLocaleData = dayjs.localeData() const momentLocaleData = moment.localeData() expect(dayjsLocaleData.firstDayOfWeek()).toBe(momentLocaleData.firstDayOfWeek()) expect(dayjsLocaleData.months()).toEqual(momentLocaleData.months()) expect(dayjsLocaleData.monthsShort()).toEqual(momentLocaleData.monthsShort()) expect(dayjsLocaleData.weekdays()).toEqual(momentLocaleData.weekdays()) expect(dayjsLocaleData.weekdaysShort()).toEqual(momentLocaleData.weekdaysShort()) expect(dayjsLocaleData.weekdaysMin()).toEqual(momentLocaleData.weekdaysMin()) const longDateFormats = ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL', 'l', 'll', 'lll', 'llll'] longDateFormats.forEach((f) => { expect(dayjsLocaleData.longDateFormat(f)).toEqual(momentLocaleData.longDateFormat(f)) }) }) }) it('Listing the months and weekdays', () => { ['zh-cn', 'en', 'fr'].forEach((lo) => { dayjs.locale(lo) moment.locale(lo) expect(dayjs.months()).toEqual(moment.months()) expect(dayjs.monthsShort()).toEqual(moment.monthsShort()) expect(dayjs.weekdays()).toEqual(moment.weekdays()) expect(dayjs.weekdaysShort()).toEqual(moment.weekdaysShort()) expect(dayjs.weekdaysMin()).toEqual(moment.weekdaysMin()) }) }) it('Month function', () => { const dayjsLocaleData = dayjs().locale('ru').localeData() const momentLocaleData = moment().locale('ru').localeData() expect(dayjsLocaleData.months()).toEqual(momentLocaleData.months()) expect(dayjsLocaleData.monthsShort()).toEqual(momentLocaleData.monthsShort()) dayjs.locale('ru') moment.locale('ru') expect(dayjs.months()).toEqual(moment.months()) expect(dayjs.monthsShort()).toEqual(moment.monthsShort()) }) it('Locale order', () => { dayjs.locale('fr') moment.locale('fr') expect(dayjs.weekdays(true)).toEqual(moment.weekdays(true)) expect(dayjs.weekdaysShort(true)).toEqual(moment.weekdaysShort(true)) expect(dayjs.weekdaysMin(true)).toEqual(moment.weekdaysMin(true)) expect(dayjs.weekdays()).not.toEqual(dayjs.weekdays(true)) dayjs.locale('en') moment.locale('en') expect(dayjs.weekdays(true)).toEqual(moment.weekdays(true)) }) it('meridiem', () => { dayjs.locale('zh-cn') expect(typeof dayjs.localeData().meridiem).toEqual('function') expect(typeof dayjs().localeData().meridiem).toEqual('function') dayjs.locale('en') }) it('ordinal', () => { dayjs.locale('zh-cn') expect(typeof dayjs.localeData().ordinal).toEqual('function') expect(typeof dayjs().localeData().ordinal).toEqual('function') dayjs.locale('en') }) ================================================ FILE: test/plugin/localizedFormat.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import es from '../../src/locale/es' import znCn from '../../src/locale/zh-cn' import localizedFormat from '../../src/plugin/localizedFormat' dayjs.extend(localizedFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Declares English localized formats', () => { expect(dayjs.en).toBeDefined() expect(dayjs.en.formats).toBeDefined(); ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => expect(dayjs.en.formats[option]).toBeDefined()) }) it('Should not interpolate characters inside square brackets', () => { const date = new Date(0) const actualDate = dayjs(date) const expectedDate = moment(date) expect(actualDate.format('[l]')).toBe('l') expect(actualDate.format('YYYY [l] YYYY')).toBe('1970 l 1970') expect(actualDate.format('l [l] l')).toBe('1/1/1970 l 1/1/1970') expect(actualDate.format('[L LL LLL LLLL]')).toBe(expectedDate.format('[L LL LLL LLLL]')) const localeFormats = { L: '[MMMM MM DD dddd]' } const mockedDayJsLocale = { ...es, name: 'fake-locale', formats: { ...localeFormats } } const fakeDate = dayjs(date, { locale: mockedDayJsLocale }) expect(fakeDate.locale('fake-locale').format('l')).toEqual('MMMM MM DD dddd') }) it('Recognizes localized format options', () => { const { formats } = dayjs.en const date = dayjs(); ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => expect(date.format(option)).toBe(date.format(formats[option]))) }) it('Uses correct English formats', () => { const date = new Date() const actualDate = dayjs(date) const expectedDate = moment(date); ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => expect(actualDate.format(option)).toBe(expectedDate.format(option))) }) it('Uses English formats in other locales as default', () => { const date = new Date() const actualDate = dayjs(date) const expectedDate = moment(date) const mockLocale = { name: 'mock', weekdays: Array(7).fill(' '), months: Array(12).fill(' ') } expect(actualDate.locale(mockLocale).format('L')).toBe(expectedDate.format('L')) }) it('Leaves the default format intact', () => { const date = new Date() const actualDate = dayjs(date) const expectedDate = moment(date) expect(actualDate.format()).toBe(expectedDate.format()) }) it('Uses the locale of the dayjs instance', () => { const date = new Date() const englishDate = dayjs(date) const spanishDate = dayjs(date, { locale: es }) expect(englishDate.format('L LTS')).not.toBe(spanishDate.format('L LTS')) }) it('Uses the localized lowercase formats if defined', () => { const date = new Date() const znDate = dayjs(date, { locale: znCn }); ['l', 'll', 'lll', 'llll'].forEach(option => expect(znDate.format(option)).toBe(znDate.format(znCn.formats[option]))) }) it('Uses fallback to xx if xx-yy not available', () => { expect(dayjs('2019-02-01').locale('en-yy').format('MMMM')) .toBe('February') }) it('Uses xx-yy if xx-YY is provided', () => { expect(dayjs('2019-02-01').locale('es-US').format('MMMM')) .toBe('febrero') }) it('Uses the localized uppercase formats as a base for lowercase formats, if not defined', () => { const date = new Date() const spanishDate = dayjs(date, { locale: es }); ['l', 'll', 'lll', 'llll'].forEach((option) => { const upperCaseFormat = es.formats[option.toUpperCase()] const adaptedFormat = upperCaseFormat.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1)) expect(spanishDate.format(option)).toBe(spanishDate.format(adaptedFormat)) }) }) ================================================ FILE: test/plugin/minMax.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import minMax from '../../src/plugin/minMax' dayjs.extend(minMax) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const arg1 = dayjs('2019-01-01') const arg2 = dayjs('2018-01-01') const arg3 = dayjs('2017-01-01') const arg4 = dayjs('Invalid Date') it('Return current time if no argument', () => { expect(dayjs.max()) .toBe(null) expect(dayjs.min()) .toBe(null) expect(dayjs.max(null)) .toBe(null) expect(dayjs.min(null)) .toBe(null) }) it('Return current time if passing empty array', () => { expect(dayjs.max([])) .toBe(null) expect(dayjs.min([])) .toBe(null) }) it('Compare between arguments', () => { expect(dayjs.max(arg1, arg2, arg3).format()) .toBe(arg1.format()) expect(dayjs.min(arg1, arg2, arg3).format()) .toBe(arg3.format()) }) it('Compare in array', () => { expect(dayjs.max([arg1, arg2, arg3]).format()) .toBe(arg1.format()) expect(dayjs.min([arg1, arg2, arg3]).format()) .toBe(arg3.format()) }) it('If Invalid Date return Invalid Date', () => { expect(dayjs.max(arg1, arg2, arg3, arg4).format()) .toBe(arg4.format()) expect(dayjs.min([arg1, arg2, arg3, arg4]).format()) .toBe(arg4.format()) }) it('Ignore if exists an "null" argument', () => { expect(dayjs.max(null, null, arg1, arg2, null, arg3).format()) .toBe(arg1.format()) expect(dayjs.min([null, null, arg1, arg2, null, arg3]).format()) .toBe(arg3.format()) }) it('Return the only date if just provided one argument', () => { expect(dayjs.max(arg1).format()) .toBe(arg1.format()) expect(dayjs.min([arg1]).format()) .toBe(arg1.format()) }) ================================================ FILE: test/plugin/negativeYear.test.js ================================================ import MockDate from 'mockdate' import dayjs from 'dayjs' import negativeYear from '../../src/plugin/negativeYear' import utc from '../../src/plugin/utc' import { REGEX_PARSE } from '../../src/constant' dayjs.extend(negativeYear) dayjs.extend(utc) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('negativeYear', () => { it('parses negative years', () => { expect(dayjs('-2020-01-01').year()).toBe(-2020) const date = '-2021/01/03' const date2 = '01/03/-2021' const date3 = '01-03--2021' const date4 = '-03-15' const d = date.match(REGEX_PARSE) expect(dayjs(date).format('YYYY-MM-DD')).toBe('-2021-01-03') expect(dayjs(date2).format('YYYY-MM-DD')).toBe('Invalid Date') expect(dayjs(date3).format()).toBe('Invalid Date') expect(dayjs(date4).format('YYYY-MM-DD')).toBe('2001-03-15') expect(d).toBe(null) }) it('does not parse non-negative years', () => { expect(dayjs('2020-01-01').year()).toBe(2020) }) it('works with other plugins', () => { expect(dayjs.utc('-2020-01-01').year()).toBe(-2020) }) it('Add and subtract with negative years', () => { expect(dayjs('-2006').add(1, 'y')).toEqual(dayjs('-2005')) expect(dayjs('-2006').subtract(1, 'y')).toEqual(dayjs('-2007')) expect(dayjs('-2006').add(1, 'y').format('YYYY')).toBe(dayjs('-2005').format('YYYY')) expect(dayjs('-2006').subtract(1, 'y').format('YYYY')).toBe(dayjs('-2007').format('YYYY')) }) it('Compare date with negative years', () => { expect(dayjs('-2006').isAfter(dayjs('-2007'))).toBeTruthy() expect(dayjs('-2006').isBefore(dayjs('-2005'))).toBeTruthy() expect(dayjs('-2006').isSame('-2006')).toBeTruthy() }) }) ================================================ FILE: test/plugin/objectSupport.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import objectSupport from '../../src/plugin/objectSupport' import quarterOfYear from '../../src/plugin/quarterOfYear' import utc from '../../src/plugin/utc' import utils from '../../src/utils' dayjs.extend(utc) dayjs.extend(quarterOfYear) dayjs.extend(objectSupport) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const now = new Date() const currentYear = now.getFullYear() const currentMonth = utils.s(now.getMonth() + 1, 2, '0') const currentDate = utils.s(now.getDate(), 2, '0') const currentUTCYear = now.getUTCFullYear() const currentUTCMonth = utils.s(now.getUTCMonth() + 1, 2, '0') const currentUTCDate = utils.s(now.getUTCDate(), 2, '0') const fmt = 'YYYY-MM-DD HH:mm:ss.SSS' const tests = [ [{ year: 2010 }, '2010-01-01 00:00:00.000'], [{ year: 2010, month: 1 }, '2010-02-01 00:00:00.000'], [{ year: 2010, month: 1, day: 12 }, '2010-02-12 00:00:00.000'], [{ year: 2010, month: 1, date: 12 }, '2010-02-12 00:00:00.000'], [ { hour: 15, minute: 25, second: 50, millisecond: 125 }, `${currentYear}-${currentMonth}-${currentDate} 15:25:50.125`, `${currentUTCYear}-${currentUTCMonth}-${currentUTCDate} 15:25:50.125`], [ { year: 2010, month: 1, day: 12, hours: 1 }, '2010-02-12 01:00:00.000' ], [ { year: 2010, month: 1, date: 12, hours: 1 }, '2010-02-12 01:00:00.000' ], [ { year: 2010, month: 1, day: 12, hours: 1, minutes: 1 }, '2010-02-12 01:01:00.000' ], [ { year: 2010, month: 1, date: 12, hours: 1, minutes: 1 }, '2010-02-12 01:01:00.000' ], [ { year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1 }, '2010-02-12 01:01:01.000' ], [ { year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1, milliseconds: 1 }, '2010-02-12 01:01:01.001' ], [ { years: 2010, months: 1, days: 14, hours: 15, minutes: 25, seconds: 50, milliseconds: 125 }, '2010-02-14 15:25:50.125' ], [ { year: 2010, month: 1, day: 14, hour: 15, minute: 25, second: 50, millisecond: 125 }, '2010-02-14 15:25:50.125' ], [ { y: 2010, M: 1, d: 14, h: 15, m: 25, s: 50, ms: 125 }, '2010-02-14 15:25:50.125' ] ] describe('parse empty object', () => { it('local', () => { expect(dayjs({}).format()) .toBe(moment({}).format()) }) it('utc', () => { expect(dayjs.utc({}).format()) .toBe(moment.utc({}).format()) }) }) it('Constructor from Object', () => { for (let i = 0; i < tests.length; i += 1) { expect(dayjs(tests[i][0]).format(fmt)).toBe(tests[i][1]) expect(moment(tests[i][0]).format(fmt)).toBe(tests[i][1]) } }) it('Constructor from Object UTC', () => { for (let i = 0; i < tests.length; i += 1) { const result = tests[i][2] || tests[i][1] expect(dayjs.utc(tests[i][0]).format(fmt)).toBe(result) expect(moment.utc(tests[i][0]).format(fmt)).toBe(result) } }) it('Constructor from null should return Invalid Date', () => { expect(dayjs(null).isValid()).toBe(false) expect(moment(null).isValid()).toBe(false) }) it('Set from Object', () => { for (let i = 0; i < tests.length; i += 1) { expect(dayjs(now).set(tests[i][0]).format(fmt)).toBe(moment(now).set(tests[i][0]).format(fmt)) } }) it('add short reverse args', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add({ ms: 50 }).millisecond()).toBe(550) expect(a.add({ s: 1 }).second()).toBe(9) expect(a.add({ m: 1 }).minute()).toBe(8) expect(a.add({ h: 1 }).hour()).toBe(7) expect(a.add({ d: 1 }).date()).toBe(13) expect(a.add({ w: 1 }).date()).toBe(19) expect(a.add({ M: 1 }).month()).toBe(10) expect(a.add({ y: 1 }).year()).toBe(2012) expect(a.add({ Q: 1 }).month()).toBe(0) const aM = moment({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(aM.clone().add({ ms: 50 }).millisecond()).toBe(550) expect(aM.clone().add({ s: 1 }).second()).toBe(9) expect(aM.clone().add({ m: 1 }).minute()).toBe(8) expect(aM.clone().add({ h: 1 }).hour()).toBe(7) expect(aM.clone().add({ d: 1 }).date()).toBe(13) expect(aM.clone().add({ w: 1 }).date()).toBe(19) expect(aM.clone().add({ M: 1 }).month()).toBe(10) expect(aM.clone().add({ y: 1 }).year()).toBe(2012) expect(aM.clone().add({ Q: 1 }).month()).toBe(0) const b = dayjs([2010, 1, 31]).add({ M: 1 }) const c = dayjs([2010, 2, 28]).subtract({ M: 1 }) const d = dayjs([2010, 2, 28]).subtract({ Q: 1 }) expect(b.month()).toBe(1) expect(b.date()).toBe(28) expect(c.month()).toBe(0) expect(c.date()).toBe(28) expect(d.month()).toBe(10) expect(d.date()).toBe(28) expect(d.year()).toBe(2009) }) it('add long reverse args', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add({ milliseconds: 50 }).millisecond()).toBe(550) expect(a.add({ seconds: 1 }).second()).toBe(9) expect(a.add({ minutes: 1 }).minute()).toBe(8) expect(a.add({ hours: 1 }).hour()).toBe(7) expect(a.add({ days: 1 }).date()).toBe(13) expect(a.add({ weeks: 1 }).date()).toBe(19) expect(a.add({ months: 1 }).month()).toBe(10) expect(a.add({ years: 1 }).year()).toBe(2012) expect(a.add({ quarters: 1 }).month()).toBe(0) }) it('add long singular reverse args', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add({ millisecond: 50 }).millisecond()).toBe(550) expect(a.add({ second: 1 }).second()).toBe(9) expect(a.add({ minute: 1 }).minute()).toBe(8) expect(a.add({ hour: 1 }).hour()).toBe(7) expect(a.add({ day: 1 }).date()).toBe(13) expect(a.add({ week: 1 }).date()).toBe(19) expect(a.add({ month: 1 }).month()).toBe(10) expect(a.add({ year: 1 }).year()).toBe(2012) expect(a.add({ quarter: 1 }).month()).toBe(0) }) it('add string long', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add(50, 'millisecond').millisecond()).toBe(550) expect(a.add(1, 'second').second()).toBe(9) expect(a.add(1, 'minute').minute()).toBe(8) expect(a.add(1, 'hour').hour()).toBe(7) expect(a.add(1, 'day').date()).toBe(13) expect(a.add(1, 'week').date()).toBe(19) expect(a.add(1, 'month').month()).toBe(10) expect(a.add(1, 'year').year()).toBe(2012) expect(a.add(1, 'quarter').month()).toBe(0) }) it('add string long singular', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add(50, 'milliseconds').millisecond()).toBe(550) expect(a.add(1, 'seconds').second()).toBe(9) expect(a.add(1, 'minutes').minute()).toBe(8) expect(a.add(1, 'hours').hour()).toBe(7) expect(a.add(1, 'days').date()).toBe(13) expect(a.add(1, 'weeks').date()).toBe(19) expect(a.add(1, 'months').month()).toBe(10) expect(a.add(1, 'years').year()).toBe(2012) expect(a.add(1, 'quarters').month()).toBe(0) }) it('add string short', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add(50, 'ms').millisecond()).toBe(550) expect(a.add(1, 's').second()).toBe(9) expect(a.add(1, 'm').minute()).toBe(8) expect(a.add(1, 'h').hour()).toBe(7) expect(a.add(1, 'd').date()).toBe(13) expect(a.add(1, 'w').date()).toBe(19) expect(a.add(1, 'M').month()).toBe(10) expect(a.add(1, 'y').year()).toBe(2012) expect(a.add(1, 'Q').month()).toBe(0) }) it('add strings string short', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add('50', 'ms').millisecond()).toBe(550) expect(a.add('1', 's').second()).toBe(9) expect(a.add('1', 'm').minute()).toBe(8) expect(a.add('1', 'h').hour()).toBe(7) expect(a.add('1', 'd').date()).toBe(13) expect(a.add('1', 'w').date()).toBe(19) expect(a.add('1', 'M').month()).toBe(10) expect(a.add('1', 'y').year()).toBe(2012) expect(a.add('1', 'Q').month()).toBe(0) }) it('add no string with milliseconds default', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.add(50).millisecond()).toBe(550) }) it('subtract strings string short', () => { const a = dayjs({ year: 2011, month: 9, date: 12, hour: 6, minute: 7, second: 8, millisecond: 500 }) expect(a.subtract('50', 'ms').millisecond()).toBe(450) expect(a.subtract('1', 's').second()).toBe(7) expect(a.subtract('1', 'm').minute()).toBe(6) expect(a.subtract('1', 'h').hour()).toBe(5) expect(a.subtract('1', 'd').date()).toBe(11) expect(a.subtract('1', 'w').date()).toBe(5) expect(a.subtract('1', 'M').month()).toBe(8) expect(a.subtract('1', 'y').year()).toBe(2010) expect(a.subtract('1', 'Q').month()).toBe(6) }) it('add decimal values of days and months', () => { expect(dayjs([2016, 4, 3]).add(1.6, 'days').date()).toBe(5) expect(dayjs([2016, 4, 3]).add(-1.6, 'days').date()).toBe(1) expect(dayjs([2016, 4, 1]).add(-1.6, 'days').date()).toBe(30) expect(dayjs([2016, 4, 3]).add(1.6, 'months').month()).toBe(4) expect(dayjs([2016, 4, 3]).add(-1.6, 'months').month()).toBe(1) expect(dayjs([2016, 1, 3]).add(-1.6, 'months').month()).toBe(11) expect(dayjs([2016, 4, 3]).subtract(1.6, 'days').date()).toBe(1) expect(dayjs([2016, 4, 2]).subtract(1.6, 'days').date()).toBe(31) expect(dayjs([2016, 2, 1]).subtract(1.1, 'days').date()).toBe(31) expect(dayjs([2016, 4, 3]).subtract(-1.6, 'days').date()).toBe(5) expect(dayjs([2016, 4, 30]).subtract(-1.6, 'days').date()).toBe(2) expect(dayjs([2016, 4, 3]).subtract(1.6, 'months').month()).toBe(1) expect(dayjs([2016, 4, 3]).subtract(-1.6, 'months').month()).toBe(4) expect(dayjs([2016, 12, 31]).subtract(-1.6, 'months').month()).toBe(0) expect(dayjs([2016, 1, 1]).add(1.6, 'years').format('YYYY-MM-DD')).toBe('2017-01-01') expect(dayjs([2016, 7, 1]).add(1.6, 'years').format('YYYY-MM-DD')).toBe('2017-07-01') expect(dayjs([2016, 1, 1]).add(1.1, 'quarters').format('YYYY-MM-DD')).toBe('2016-04-01') }) it('returns valid date on undefined', () => { expect(dayjs().isValid()).toBe(true) }) it('returns invalid date on null', () => { expect(dayjs(null).isValid()).toBe(false) }) ================================================ FILE: test/plugin/pluralGetSet.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import pluralGetSet from '../../src/plugin/pluralGetSet' dayjs.extend(pluralGetSet) const warnBackup = global.console.warn beforeEach(() => { MockDate.set(new Date()) global.console.warn = jest.genMockFunction() // moment.js .years, .dates, .months will throw warn }) afterEach(() => { MockDate.reset() global.console.warn = warnBackup }) it('Years', () => { expect(dayjs().get('years')).toBe(moment().get('years')) expect(dayjs().years()).toBe(moment().years()) expect(dayjs().years(0).valueOf()).toBe(moment().years(0).valueOf()) expect(dayjs().years(2000).valueOf()).toBe(moment().years(2000).valueOf()) }) it('Months', () => { expect(dayjs().get('months')).toBe(moment().get('months')) expect(dayjs().months()).toBe(moment().months()) expect(dayjs().months(0).valueOf()).toBe(moment().months(0).valueOf()) expect(dayjs().months(1).valueOf()).toBe(moment().months(1).valueOf()) }) it('Days of Week', () => { expect(dayjs().get('days')).toBe(moment().get('days')) expect(dayjs().days()).toBe(moment().days()) expect(dayjs().days(0).format()).toBe(moment().days(0).format()) expect(dayjs().days(1).format()).toBe(moment().days(1).format()) }) it('Dates', () => { expect(dayjs().get('dates')).toBe(moment().get('dates')) expect(dayjs().dates()).toBe(moment().dates()) expect(dayjs().dates(0).valueOf()).toBe(moment().dates(0).valueOf()) expect(dayjs().dates(1).valueOf()).toBe(moment().dates(1).valueOf()) }) it('Hours', () => { expect(dayjs().get('hours')).toBe(moment().get('hours')) expect(dayjs().hours()).toBe(moment().hours()) expect(dayjs().hours(0).valueOf()).toBe(moment().hours(0).valueOf()) expect(dayjs().hours(1).valueOf()).toBe(moment().hours(1).valueOf()) }) it('Minutes', () => { expect(dayjs().get('minutes')).toBe(moment().get('minutes')) expect(dayjs().minutes()).toBe(moment().minutes()) expect(dayjs().minutes(0).valueOf()).toBe(moment().minutes(0).valueOf()) expect(dayjs().minutes(1).valueOf()).toBe(moment().minutes(1).valueOf()) }) it('Seconds', () => { expect(dayjs().get('seconds')).toBe(moment().get('seconds')) expect(dayjs().seconds()).toBe(moment().seconds()) expect(dayjs().seconds(0).valueOf()).toBe(moment().seconds(0).valueOf()) expect(dayjs().seconds(1).valueOf()).toBe(moment().seconds(1).valueOf()) }) it('Milliseconds', () => { expect(dayjs().get('milliseconds')).toBe(moment().get('milliseconds')) expect(dayjs().milliseconds()).toBe(moment().milliseconds()) expect(dayjs().milliseconds(0).valueOf()).toBe(moment().milliseconds(0).valueOf()) expect(dayjs().milliseconds(1).valueOf()).toBe(moment().milliseconds(1).valueOf()) }) it('Set Dates', () => { expect(dayjs().date(30).valueOf()).toBe(moment().dates(30).valueOf()) expect(dayjs().set('dates', 30).valueOf()).toBe(moment().set('dates', 30).valueOf()) }) it('Set Days of Week', () => { expect(dayjs().days(0).valueOf()).toBe(moment().days(0).valueOf()) expect(dayjs().set('days', 0).valueOf()).toBe(moment().set('days', 0).valueOf()) }) it('Set Months', () => { expect(dayjs().months(11).valueOf()).toBe(moment().months(11).valueOf()) expect(dayjs().set('months', 11).valueOf()).toBe(moment().set('months', 11).valueOf()) }) it('Set Years', () => { expect(dayjs().years(2008).valueOf()).toBe(moment().year(2008).valueOf()) expect(dayjs().set('years', 2008).valueOf()).toBe(moment().set('years', 2008).valueOf()) }) it('Set Hours', () => { expect(dayjs().set('hours', 6).valueOf()).toBe(moment().set('hours', 6).valueOf()) expect(dayjs().hours(6).valueOf()).toBe(moment().hours(6).valueOf()) }) it('Set Minutes', () => { expect(dayjs().minutes(59).valueOf()).toBe(moment().minutes(59).valueOf()) expect(dayjs().set('minutes', 59).valueOf()).toBe(moment().set('minutes', 59).valueOf()) }) it('Set Seconds', () => { expect(dayjs().seconds(59).valueOf()).toBe(moment().seconds(59).valueOf()) expect(dayjs().set('second', 59).valueOf()).toBe(moment().set('second', 59).valueOf()) }) it('Set Milliseconds', () => { expect(dayjs().milliseconds(999).valueOf()).toBe(moment().milliseconds(999).valueOf()) expect(dayjs().set('millisecond', 999).valueOf()).toBe(moment().set('millisecond', 999).valueOf()) }) it('Set Month and Year in last day of month', () => { // 2011-07-31 -> 2011-02-28 const origin = dayjs('2011-07-31T14:48:00.000Z') const setMonth = origin.set('month', 1) expect(setMonth.months()).toBe(1) expect(origin.dates()).toBe(31) expect(setMonth.dates()).toBe(28) // 2000-02-29 -> 2001-02-28 const origin2 = dayjs('2000-02-29T14:48:00.000Z') const setYear = origin2.set('years', 2001) expect(setYear.months()).toBe(1) expect(origin2.dates()).toBe(29) expect(setYear.dates()).toBe(28) }) ================================================ FILE: test/plugin/preParsePostFormat.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../../src' import preParsePostFormat from '../../src/plugin/preParsePostFormat' import localeData from '../../src/plugin/localeData' import duration from '../../src/plugin/duration' import calendar from '../../src/plugin/calendar' import objectSupport from '../../src/plugin/objectSupport' import customParseFormat from '../../src/plugin/customParseFormat' import relativeTime from '../../src/plugin/relativeTime' import utc from '../../src/plugin/utc' import arraySupport from '../../src/plugin/arraySupport' import en from '../../src/locale/en' dayjs.extend(utc) dayjs.extend(localeData) dayjs.extend(customParseFormat) dayjs.extend(arraySupport) dayjs.extend(objectSupport) dayjs.extend(calendar) dayjs.extend(duration) dayjs.extend(relativeTime) dayjs.extend(preParsePostFormat) const symbolMap = { 1: '!', 2: '@', 3: '#', 4: '$', 5: '%', 6: '^', 7: '&', 8: '*', 9: '(', 0: ')' } const numberMap = { '!': '1', '@': '2', '#': '3', $: '4', '%': '5', '^': '6', '&': '7', '*': '8', '(': '9', ')': '0' } const localeCustomizations = { ...en, preparse(string) { if (typeof string !== 'string') { throw new Error(`preparse - Expected string, got ${typeof string}`) } try { return string.replace(/[!@#$%^&*()]/g, match => numberMap[match]) } catch (error) { throw new Error(`Unexpected error during preparse of '${string}' - ${error}`) } }, postformat(string) { if (typeof string !== 'string') { throw new Error(`postformat - Expected string, got ${typeof string}`) } try { return string.replace(/\d/g, match => symbolMap[match]) } catch (error) { throw new Error(`Unexpected error during postFormat of '${string}' - ${error}`) } } } beforeEach(() => { MockDate.set(new Date()) dayjs.locale('symbol', localeCustomizations) }) afterEach(() => { MockDate.reset() dayjs.locale('symbol', null) }) describe('preparse and postformat', () => { describe('transform', () => { const TEST_DATE = '@)!@-)*-@&' const TEST_NUM = 1346025600 it('preparse string + format', () => expect(dayjs.utc(TEST_DATE, 'YYYY-MM-DD').unix()).toBe(TEST_NUM)) it('preparse ISO8601 string', () => expect(dayjs.utc(TEST_DATE).unix()).toBe(TEST_NUM)) it('postformat', () => expect(dayjs .unix(TEST_NUM) .utc() .format('YYYY-MM-DD')) .toBe(TEST_DATE)) }) describe('transform from', () => { dayjs.locale('symbol', localeCustomizations) const start = dayjs([2007, 1, 28]) const t1 = dayjs([2007, 1, 28]).add({ s: 90 }) it('postformat should work on dayjs.fn.from', () => expect(start.from(t1, true)).toBe('@ minutes')) const t2 = dayjs().add(6, 'd') it('postformat should work on dayjs.fn.fromNow', () => expect(t2.fromNow(true)).toBe('^ days')) it('postformat should work on dayjs.duration.fn.humanize', () => expect(dayjs.duration(10, 'h').humanize()).toBe('!) hours')) }) }) describe('calendar day', () => { const a = dayjs() .hour(12) .minute(0) .second(0) it('today at the same time', () => expect(dayjs(a).calendar()).toBe('Today at !@:)) PM')) it('Now plus 25 min', () => expect(dayjs(a) .add({ m: 25 }) .calendar()) .toBe('Today at !@:@% PM')) it('Now plus 1 hour', () => expect(dayjs(a) .add({ h: 1 }) .calendar()) .toBe('Today at !:)) PM')) it('tomorrow at the same time', () => expect(dayjs(a) .add({ d: 1 }) .calendar()) .toBe('Tomorrow at !@:)) PM')) it('Now minus 1 hour', () => expect(dayjs(a) .subtract({ h: 1 }) .calendar()) .toBe('Today at !!:)) AM')) it('yesterday at the same time', () => expect(dayjs(a) .subtract({ d: 1 }) .calendar()) .toBe('Yesterday at !@:)) PM')) }) ================================================ FILE: test/plugin/quarterOfYear.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import quarterOfYear from '../../src/plugin/quarterOfYear' dayjs.extend(quarterOfYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('get QuarterOfYear', () => { expect(dayjs('2013-01-01T00:00:00.000').quarter()).toBe(1) expect(dayjs('2013-04-01T00:00:00.000').subtract(1, 'ms').quarter()).toBe(1) expect(dayjs('2013-04-01T00:00:00.000').quarter()).toBe(2) expect(dayjs('2013-07-01T00:00:00.000').subtract(1, 'ms').quarter()).toBe(2) expect(dayjs('2013-07-01T00:00:00.000').quarter()).toBe(3) expect(dayjs('2013-10-01T00:00:00.000').subtract(1, 'ms').quarter()).toBe(3) expect(dayjs('2013-10-01T00:00:00.000').quarter()).toBe(4) expect(dayjs('2014-01-01T00:00:00.000').subtract(1, 'ms').quarter()).toBe(4) }) it('set QuarterOfYear', () => { const d1 = '2013-01-01T00:00:00.000' expect(dayjs(d1).quarter(2).format()) .toBe(moment(d1).quarter(2).format()) const d2 = '2013-02-05T05:06:07.000' expect(dayjs(d2).quarter(2).format()) .toBe(moment(d2).quarter(2).format()) const d3 = '2018-11-25T05:06:07.000' expect(dayjs(d3).quarter(3).format()) .toBe(moment(d3).quarter(3).format()) }) it('add subtract quarter', () => { expect(dayjs().add(2, 'quarter').format()) .toBe(moment().add(2, 'quarter').format()) expect(dayjs().subtract(2, 'quarter').format()) .toBe(moment().subtract(2, 'quarter').format()) }) it('startOf endOf quarter', () => { expect(dayjs().startOf('quarter').format()) .toBe(moment().startOf('quarter').format()) expect(dayjs().endOf('quarter').format()) .toBe(moment().endOf('quarter').format()) }) ================================================ FILE: test/plugin/relativeTime.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import * as C from '../../src/constant' import relativeTime from '../../src/plugin/relativeTime' import updateLocale from '../../src/plugin/updateLocale' import utc from '../../src/plugin/utc' import '../../src/locale/ru' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date('2018-04-04T16:00:00.000Z')) }) afterEach(() => { MockDate.reset() }) it('Time from X', () => { const T = [ [0, 'second'], // a few seconds [1, 'second'], // a few seconds [44, 'second'], // a few seconds [44.4, 'second'], // a few seconds [44.5, 'second'], // a minute [45, 'second'], // a minute [1, 'minute'], // a minute [89, 'second'], // a minute [89.4, 'second'], // a minute [89.5, 'second'], // a minute [90, 'second'], // 2 minutes [44, 'minute'], // 44 minutes [44.4, 'minute'], [44.5, 'minute'], [45, 'minute'], // an hour [1, 'hour'], // an hour [89, 'minute'], // an hour [89.4, 'minute'], [89.5, 'minute'], [90, 'minute'], // 2 hours [21, 'hour'], // 21 hours [21.4, 'hour'], [21.5, 'hour'], [22, 'hour'], // a day [1, 'day'], // a day [35, 'hour'], // a day [35.4, 'hour'], [35.5, 'hour'], [36, 'hour'], // 2 days [25, 'day'], // 25 days [26, 'day'], // a month [1, 'month'], // a month [45, 'day'], // a month [47, 'day'], // 2 month [10, 'month'], // 10 month [11, 'month'], // a year [1, 'year'], // a year [17, 'month'], // a year [18, 'month'] // 2 years ] T.forEach((t) => { expect(dayjs().from(dayjs().add(t[0], t[1]))).toBe(moment().from(moment().add(t[0], t[1]))) }) // withoutSuffix expect(dayjs().from(dayjs().add(3, 'year'), true)).toBe(moment().from(moment().add(3, 'year'), true)) // past date expect(dayjs().from(dayjs().subtract(3, 'year'))).toBe(moment().from(moment().subtract(3, 'year'))) }) it('Time from now', () => { expect(dayjs().fromNow()).toBe(moment().fromNow()) expect(dayjs().fromNow(true)).toBe(moment().fromNow(true)) }) it('Time to now', () => { expect(dayjs().toNow()).toBe(moment().toNow()) expect(dayjs().toNow(true)).toBe(moment().toNow(true)) }) it('Time to X', () => { // withoutSuffix expect(dayjs().to(dayjs().add(3, 'year'), true)).toBe(moment().to(moment().add(3, 'year'), true)) // past date expect(dayjs().to(dayjs().subtract(3, 'year'))).toBe(moment().to(moment().subtract(3, 'year'))) }) it('Locale Function', () => { // e.g. in ru locale, m: x minute require additional processing // and provides as a function instead of a string const str0 = '2020-01-06 15:53:00' const str = '2020-01-06 15:52:15' const result = dayjs(str0).locale('ru').to(str) expect(result).toEqual(expect.any(String)) }) // https://github.com/iamkun/dayjs/issues/646 it('Time from now with UTC', () => { dayjs.extend(utc) expect(dayjs.utc().fromNow()).toBe(moment.utc().fromNow()) const currentTime = new Date() const currentTimestamp = currentTime.getTime() const currentTimestampAfter37hrs = currentTimestamp + (37 * 60 * 60 * 1000) let dutc = dayjs.utc(currentTimestampAfter37hrs) let mutc = moment.utc(currentTimestampAfter37hrs) expect(dutc.fromNow()).toBe(mutc.fromNow()) // More precise const currentTimestampAfter36hrs = currentTimestamp + (36.0001 * 60 * 60 * 1000) dutc = dayjs.utc(currentTimestampAfter36hrs) mutc = moment.utc(currentTimestampAfter36hrs) expect(dutc.fromNow()).toBe(mutc.fromNow()) }) it('Custom thresholds and rounding support', () => { expect(dayjs().subtract(45, 'm').fromNow()).toBe('an hour ago') delete relativeTime.$i // this allow plugin to be installed again dayjs.extend(relativeTime, { rounding: Math.floor, thresholds: [ { l: 's', r: 1 }, { l: 'm', r: 1 }, { l: 'mm', r: 59, d: C.MIN }, { l: 'h', r: 1 }, { l: 'hh', r: 23, d: C.H }, { l: 'd', r: 1 }, { l: 'dd', r: 29, d: C.D }, { l: 'M', r: 1 }, { l: 'MM', r: 11, d: C.M }, { l: 'y' }, { l: 'yy', d: C.Y } ] }) expect(dayjs().subtract(45, 'm').fromNow()).toBe('45 minutes ago') }) it('Locale without relativeTime config fallback', () => { expect(dayjs().locale({ name: 'test-locale' }).fromNow()).toEqual(expect.any(String)) }) it('Past and Future keys should support function for additional processing', () => { dayjs.extend(updateLocale) dayjs.updateLocale('en', { relativeTime: { future: input => `${input} modified`, past: input => `${input} modified`, s: 'just now', m: ' 1 min', mm: '%d min', h: '1 hr', hh: '%d hrs', d: 'a day', dd: '%d days', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years' } }) const past = Date.now() - 1000 expect(dayjs(past).fromNow()).toEqual(' 1 min modified') const future = Date.now() + 1000 expect(dayjs(future).fromNow()).toEqual(' 1 min modified') }) ================================================ FILE: test/plugin/timezone.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment-timezone' import dayjs from '../../src' import timezone from '../../src/plugin/timezone' import customParseFormat from '../../src/plugin/customParseFormat' import utc from '../../src/plugin/utc' dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(customParseFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const NY = 'America/New_York' const VAN = 'America/Vancouver' const DEN = 'America/Denver' const TOKYO = 'Asia/Tokyo' const PARIS = 'Europe/Paris' describe('Guess', () => { it('return string', () => { expect(typeof dayjs.tz.guess()).toBe('string') }) }) describe('Parse', () => { it('parse target time string', () => { const newYork = dayjs.tz('2014-06-01 12:00', NY) const MnewYork = moment.tz('2014-06-01 12:00', NY) expect(newYork.format()).toBe('2014-06-01T12:00:00-04:00') expect(newYork.format()).toBe(MnewYork.format()) expect(newYork.utcOffset()).toBe(-240) expect(newYork.utcOffset()).toBe(MnewYork.utcOffset()) expect(newYork.valueOf()).toBe(1401638400000) expect(newYork.valueOf()).toBe(MnewYork.valueOf()) }) it('parse timestamp, js Date, Day.js object', () => { const d = new Date('2020-08-07T12:00-07:00') const result = '2020-08-07T12:00:00-07:00' const TjsDate = dayjs.tz(d, VAN) const Tdayjs = dayjs.tz(dayjs(d), VAN) const Timestamp = dayjs.tz(d.getTime(), VAN) const Tmoment = moment.tz(d, VAN) expect(TjsDate.format()).toBe(result) expect(Tdayjs.format()).toBe(result) expect(Timestamp.format()).toBe(result) expect(Tmoment.format()).toBe(result) }) it('parse and convert between timezones', () => { const newYork = dayjs.tz('2014-06-01 12:00', NY) expect(newYork.tz('America/Los_Angeles').format()).toBe('2014-06-01T09:00:00-07:00') expect(newYork.tz('Europe/London').format()).toBe('2014-06-01T17:00:00+01:00') }) it('preserve milliseconds', () => { const d = dayjs(1596735327399) const oldMs = d.millisecond() const dTz = d.tz('America/New_York') const newMs = dTz.millisecond() expect(oldMs).toEqual(newMs) }) }) describe('Convert', () => { it('convert to target time', () => { const losAngeles = dayjs('2014-06-01T12:00:00Z').tz('America/Los_Angeles') const MlosAngeles = moment('2014-06-01T12:00:00Z').tz('America/Los_Angeles') expect(losAngeles.format()).toBe('2014-06-01T05:00:00-07:00') expect(losAngeles.format()).toBe(MlosAngeles.format()) expect(losAngeles.valueOf()).toBe(1401624000000) expect(losAngeles.valueOf()).toBe(MlosAngeles.valueOf()) expect(losAngeles.utcOffset()).toBe(-420) expect(losAngeles.utcOffset()).toBe(MlosAngeles.utcOffset()) }) it('convert to target time', () => { [dayjs, moment].forEach((_) => { const losAngeles = _('2014-06-01T12:00:00Z').tz('America/Los_Angeles') expect(losAngeles.format()).toBe('2014-06-01T05:00:00-07:00') expect(losAngeles.valueOf()).toBe(1401624000000) }) }) it('convert from time with timezone to target time', () => { const losAngelesInUTC = dayjs('2014-06-01T05:00:00-07:00').tz('UTC') const MlosAngelesInUTC = moment('2014-06-01T05:00:00-07:00').tz('UTC') expect(losAngelesInUTC.format()).toBe('2014-06-01T12:00:00Z') expect(losAngelesInUTC.format()).toBe(MlosAngelesInUTC.format()) }) it('DST', () => { [dayjs, moment].forEach((_) => { const jun = _('2014-06-01T12:00:00Z') const dec = _('2014-12-01T12:00:00Z') expect(jun.tz('America/Los_Angeles').format('ha')).toBe('5am') expect(jun.tz('America/Los_Angeles').utcOffset()).toBe(-7 * 60) expect(dec.tz('America/Los_Angeles').format('ha')).toBe('4am') expect(dec.tz('America/Los_Angeles').utcOffset()).toBe(-8 * 60) expect(jun.tz(NY).format('ha')).toBe('8am') expect(dec.tz(NY).format('ha')).toBe('7am') expect(jun.tz(TOKYO).format('ha')).toBe('9pm') expect(dec.tz(TOKYO).format('ha')).toBe('9pm') expect(jun.tz('Australia/Sydney').format('ha')).toBe('10pm') expect(dec.tz('Australia/Sydney').format('ha')).toBe('11pm') }) }) it('format Z', () => { [dayjs, moment].forEach((_) => { const t = _('2020-08-06T03:48:10.258Z').tz(TOKYO) expect(t.format('Z')).toBe('+09:00') }) }) }) describe('DST, a time that never existed Spring Forward', () => { // 11 March 2012, 02:00:00 clocks were // turned forward 1 hour to 11 March 2012, 03:00:00 local // daylight time instead. // 02:00 -> 03:00 // 02:59 -> 03:59 it('2012-03-11 01:59:59', () => { const s = '2012-03-11 01:59:59' const d = dayjs.tz(s, NY) const m = moment.tz(s, NY) expect(d.format()).toBe('2012-03-11T01:59:59-05:00') expect(d.format()).toBe(m.format()) expect(d.utcOffset()).toBe(-300) expect(d.utcOffset()).toBe(m.utcOffset()) expect(d.valueOf()).toBe(1331449199000) expect(d.valueOf()).toBe(m.valueOf()) }) it('2012-03-11 02:00:00', () => { const s = '2012-03-11 02:00:00' const d = dayjs.tz(s, NY) const m = moment.tz(s, NY) expect(d.format()).toBe('2012-03-11T03:00:00-04:00') expect(d.format()).toBe(m.format()) expect(d.valueOf()).toBe(m.valueOf()) expect(d.valueOf()).toBe(1331449200000) expect(d.utcOffset()).toBe(-240) expect(d.utcOffset()).toBe(m.utcOffset()) }) it('2012-03-11 02:59:59', () => { const s = '2012-03-11 02:59:59' const d = dayjs.tz(s, NY) const m = moment.tz(s, NY) expect(d.format()).toBe('2012-03-11T03:59:59-04:00') expect(d.format()).toBe(m.format()) expect(d.valueOf()).toBe(m.valueOf()) expect(d.valueOf()).toBe(1331452799000) expect(d.utcOffset()).toBe(-240) expect(d.utcOffset()).toBe(m.utcOffset()) }) it('2012-03-11 03:00:00', () => { const s = '2012-03-11 03:00:00' const d = dayjs.tz(s, NY) const m = moment.tz(s, NY) expect(d.format()).toBe('2012-03-11T03:00:00-04:00') expect(d.format()).toBe(m.format()) expect(d.valueOf()).toBe(m.valueOf()) expect(d.valueOf()).toBe(1331449200000) expect(d.utcOffset()).toBe(-240) expect(d.utcOffset()).toBe(m.utcOffset()) }) }) describe('DST, a time that never existed Fall Back', () => { // In the fall, at the end of DST it('2012-11-04 00:59:59', () => { const s = '2012-11-04 00:59:59'; [dayjs, moment].forEach((_) => { const d = _.tz(s, NY) expect(d.format()).toBe('2012-11-04T00:59:59-04:00') expect(d.utcOffset()).toBe(-240) expect(d.valueOf()).toBe(1352005199000) }) }) it('2012-11-04 00:59:59', () => { const s = '2012-11-04 00:59:59'; [dayjs, moment].forEach((_) => { const d = _.tz(s, NY) expect(d.format()).toBe('2012-11-04T00:59:59-04:00') expect(d.utcOffset()).toBe(-240) expect(d.valueOf()).toBe(1352005199000) }) }) // there's no sense to test "2012-11-04 01:59:59 America/New_York" // cause it's an invalid date and never exist // and dayjs result it as "2012-11-04T01:59:00-05:00" it('2012-11-04 02:00:00', () => { const s = '2012-11-04 02:00:00'; [dayjs, moment].forEach((_) => { const d = _.tz(s, NY) expect(d.format()).toBe('2012-11-04T02:00:00-05:00') expect(d.utcOffset()).toBe(-300) expect(d.valueOf()).toBe(1352012400000) }) }) }) it('DST valueOf', () => { const day1 = '2021-11-17T09:45:00.000Z' const d1 = dayjs.utc(day1).tz(PARIS) const m1 = moment.tz(day1, PARIS) expect(d1.valueOf()).toBe(m1.valueOf()) const day2 = '2021-05-17T09:45:00.000Z' const d2 = dayjs.utc(day2).tz(PARIS) const m2 = moment.tz(day2, PARIS) expect(d2.valueOf()).toBe(m2.valueOf()) }) describe('set Default', () => { it('default timezone', () => { const dateStr = '2014-06-01 12:00' dayjs.tz.setDefault(NY) const newYork = dayjs.tz(dateStr) expect(newYork.format()).toBe('2014-06-01T12:00:00-04:00') expect(newYork.utcOffset()).toBe(-240) expect(newYork.valueOf()).toBe(1401638400000) expect(dayjs(dateStr).tz().format()).toBe(dayjs(dateStr).tz(NY).format()) }) it('empty timezone means local timezone', () => { const LOCAL_TZ = dayjs.tz.guess() const dateStr = '2014-06-01 12:00' dayjs.tz.setDefault() expect(dayjs(dateStr).tz().valueOf()).toBe(dayjs(dateStr).tz(LOCAL_TZ).valueOf()) expect(dayjs.tz(dateStr).valueOf()).toBe(dayjs.tz(dateStr, LOCAL_TZ).valueOf()) }) it('change default timezone', () => { dayjs.tz.setDefault(NY) const newYork = dayjs.tz('2014-06-01 12:00') expect(newYork.utcOffset()).toBe(-240) dayjs.tz.setDefault(TOKYO) const tokyo = dayjs.tz('2014-06-01 12:00') expect(tokyo.format()).toBe('2014-06-01T12:00:00+09:00') expect(tokyo.format('Z')).toBe('+09:00') expect(tokyo.valueOf()).toBe(1401591600000) }) it('override default timezone in proto.tz', () => { dayjs.tz.setDefault(NY) const tokyo = dayjs.tz('2014-06-01 12:00', TOKYO) expect(tokyo.format()).toBe('2014-06-01T12:00:00+09:00') expect(tokyo.format('Z')).toBe('+09:00') expect(tokyo.valueOf()).toBe(1401591600000) }) it('override default timezone in d.tz', () => { dayjs.tz.setDefault(NY) const tokyo = dayjs.tz('2014-06-01 12:00', TOKYO) expect(tokyo.format()).toBe('2014-06-01T12:00:00+09:00') expect(tokyo.format('Z')).toBe('+09:00') expect(tokyo.valueOf()).toBe(1401591600000) }) }) describe('keepLocalTime', () => { const base = dayjs.tz('2013-11-18 11:55', 'America/Toronto') it('keepLocalTime', () => { expect(base.tz('Europe/Berlin').format()).toBe('2013-11-18T17:55:00+01:00') expect(base.tz('Europe/Berlin', true).format()).toBe('2013-11-18T11:55:00+01:00') }) }) describe('Get offsetName', () => { const dtz = dayjs.tz('2012-03-11 01:59:59', NY) it('short', () => { const d = dtz.offsetName('short') const m = moment.tz('2012-03-11 01:59:59', NY).format('z') expect(d).toBe(m) expect(d).toBe('EST') }) it('long', () => { const d = dtz.offsetName('long') expect(d).toBe('Eastern Standard Time') }) }) describe('CustomPraseFormat', () => { const result = 1602786600 it('normal', () => { expect(dayjs.tz('2020/10/15 12:30', DEN).unix()).toBe(result) }) it('custom', () => { expect(dayjs.tz('10/15/2020 12:30', 'MM/DD/YYYY HH:mm', DEN).unix()).toBe(result) }) }) describe('startOf and endOf', () => { it('corrects for timezone offset in startOf', () => { const originalDay = dayjs.tz('2010-01-01 00:00:00', NY) const startOfDay = originalDay.startOf('day') expect(startOfDay.valueOf()).toEqual(originalDay.valueOf()) }) it('corrects for timezone offset in endOf', () => { const originalDay = dayjs.tz('2009-12-31 23:59:59.999', NY) const endOfDay = originalDay.endOf('day') expect(endOfDay.valueOf()).toEqual(originalDay.valueOf()) }) it('preserves locality when tz is called', () => { const tzWithoutLocality = dayjs.tz('2023-02-17 00:00:00', NY) const tzWithLocality = dayjs.tz('2023-02-17 00:00:00', NY).locale({ name: 'locale_test', weekStart: 3 }) expect(tzWithoutLocality.startOf('week').format('YYYY-MM-DD')).toEqual('2023-02-12') expect(tzWithLocality.startOf('week').format('YYYY-MM-DD')).toEqual('2023-02-15') }) }) describe('UTC timezone', () => { it('TZ with UTC with Locale', () => { const test1 = dayjs('2000-01-01T09:00:00+09:00').tz('Asia/Seoul').locale('en') expect(test1.hour()).toBe(9) const test2 = dayjs('2000-01-01T09:00:00+09:00').tz('Asia/Hong_Kong').locale('en') expect(test2.hour()).toBe(8) const test3 = dayjs('2000-01-01T09:00:00+09:00').tz('Etc/UTC').locale('en') expect(test3.hour()).toBe(0) }) it('TZ with UTC', () => { const dayjs1 = dayjs('2000-01-01T09:01:00+09:00').tz('Etc/UTC', false) expect(dayjs1.format()).toBe('2000-01-01T00:01:00Z') const moment1 = moment('2000-01-01T09:01:00+09:00').tz('Etc/UTC', false) expect(moment1.format()).toBe('2000-01-01T00:01:00Z') const dayjs2 = dayjs('2000-01-01T09:01:00+09:00').tz('Etc/UTC', true) const moment2 = moment('2000-01-01T09:01:00+09:00').tz('Etc/UTC', true) expect(dayjs2.format()).toBe(moment2.format()) }) }) ================================================ FILE: test/plugin/toArray.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import toArray from '../../src/plugin/toArray' dayjs.extend(toArray) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('As Array -> toArray', () => { expect(dayjs().toArray()).toEqual(moment().toArray()) }) ================================================ FILE: test/plugin/toObject.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import toObject from '../../src/plugin/toObject' dayjs.extend(toObject) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('As Object -> toObject', () => { expect(dayjs().toObject()).toEqual(moment().toObject()) }) ================================================ FILE: test/plugin/updateLocale.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import updateLocale from '../../src/plugin/updateLocale' import localizedFormat from '../../src/plugin/localizedFormat' import '../../src/locale/zh-cn' dayjs.extend(updateLocale) dayjs.extend(localizedFormat) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) const newLocale = { months: new Array(12).fill('testMonth'), formats: { // formats for dayjs and longDateFormat for momentjs LT: '[testFormat]' }, longDateFormat: { LT: '[testFormat]' } } const formatString = 'MMMM LT' describe('Update locale', () => { it('Invalid argument', () => { const result = dayjs.updateLocale('InvalidLocaleName', {}) expect(result) .toEqual(undefined) expect(dayjs().format(formatString)) .toEqual(moment().format(formatString)) }) it('Return value', () => { const result1 = dayjs.updateLocale('en') expect(typeof result1).toEqual('object') const result2 = dayjs.updateLocale('en', {}) expect(typeof result2).toEqual('object') const result3 = dayjs.updateLocale('en', newLocale) expect(typeof result3).toEqual('object') }) it('Update build-in en locale', () => { moment.updateLocale('en', newLocale) dayjs.updateLocale('en', newLocale) expect(dayjs().format(formatString)) .toEqual('testMonth testFormat') expect(dayjs().format(formatString)) .toEqual(moment().format(formatString)) }) it('Update imported zh-cn locale', () => { moment.updateLocale('zh-cn', newLocale) dayjs.updateLocale('zh-cn', newLocale) dayjs.locale('zh-cn') moment.locale('zh-cn') expect(dayjs().format(formatString)) .toEqual('testMonth testFormat') expect(dayjs().format(formatString)) .toEqual(moment().format(formatString)) }) it('Partial update to nested object (formats)', () => { dayjs.locale('en') // First, get the original formats const originalLocale = dayjs.Ls.en const originalLT = originalLocale.formats && originalLocale.formats.LT // Update only L format dayjs.updateLocale('en', { formats: { L: 'DD/MM/YYYY' } }) const updatedLocale = dayjs.Ls.en // The updated key should have the new value expect(updatedLocale.formats.L).toBe('DD/MM/YYYY') // Other keys in formats should be preserved expect(updatedLocale.formats.LT).toBe(originalLT) }) it('Non-object values should still be replaced entirely', () => { const newMonths = new Array(12).fill('newMonth') dayjs.updateLocale('en', { months: newMonths }) const updatedLocale = dayjs.Ls.en expect(updatedLocale.months).toEqual(newMonths) }) it('Update invalid date string', () => { const locale = 'en' const localeSetting = { invalidDate: 'bad date' } dayjs.updateLocale(locale, localeSetting) moment.updateLocale(locale, localeSetting) dayjs.locale(locale) moment.locale(locale) expect(dayjs('').format()).toBe(moment('').format()) expect(dayjs('otherString').format()).toBe(moment('otherString').format()) }) }) ================================================ FILE: test/plugin/utc-utcOffset.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import utc from '../../src/plugin/utc' dayjs.extend(utc) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Set utcOffset -> Get utcOffset', () => { expect(dayjs().utcOffset(540).utcOffset()).toBe(moment().utcOffset(540).utcOffset()) expect(dayjs().utcOffset(540).format()).toBe(moment().utcOffset(540).format()) expect(dayjs().utcOffset(60).format()).toBe(moment().utcOffset(60).format()) expect(dayjs().utcOffset(8).format()).toBe(moment().utcOffset(8).format()) expect(dayjs().utcOffset(-540).utcOffset()).toBe(moment().utcOffset(-540).utcOffset()) expect(dayjs().utcOffset(-540).format()).toBe(moment().utcOffset(-540).format()) expect(dayjs().utcOffset(-60).format()).toBe(moment().utcOffset(-60).format()) expect(dayjs().utcOffset(-8).format()).toBe(moment().utcOffset(-8).format()) }) it('valueOf, toDate, toString, toISOString should be the same as original', () => { const d = dayjs() const du = dayjs().utcOffset(9) const mu = moment().utcOffset(9) expect(d.valueOf()).toBe(du.valueOf()) expect(du.valueOf()).toBe(mu.valueOf()) expect(d.toDate()).toEqual(du.toDate()) expect(du.toDate()).toEqual(mu.toDate()) expect(du.toISOString()).toEqual(mu.toISOString()) expect(d.toString()).toEqual(d.toString()) }) it('clone', () => { const du = dayjs().utcOffset(9) const duClone = du.clone() expect(du.valueOf()).toBe(duClone.valueOf()) expect(du.format()).toBe(duClone.format()) expect(du.utcOffset()).toBe(duClone.utcOffset()) }) it('immutable', () => { const d = dayjs() const du = d.utcOffset(d.utcOffset() + 1) expect(d.utcOffset()).not.toBe(du.utcOffset()) expect(d.format()).not.toBe(du.format()) }) it('utcOffset(0) enable utc mode', () => { expect(dayjs().utcOffset(0).format()).toBe(moment().utcOffset(0).format()) expect(dayjs().utcOffset(0).isUTC()).toBeTruthy() }) it('utcOffset keepLocalTime', () => { const d = '2000-01-01T06:00:00Z' expect(dayjs.utc(d).utcOffset(5, true).format()) .toBe(moment.utc(d).utcOffset(5, true).format()) expect(dayjs.utc(d).utcOffset(0, true).format()) .toBe(moment.utc(d).utcOffset(0, true).format()) expect(dayjs.utc(d).utcOffset(-5, true).format()) .toBe(moment.utc(d).utcOffset(-5, true).format()) const d2 = '2016-01-01 00:00:00' expect(dayjs(d2).utcOffset(0, true).format()) .toBe(moment(d2).utcOffset(0, true).format()) expect(dayjs(d2).utcOffset(-5, true).format()) .toBe(moment(d2).utcOffset(-5, true).format()) expect(dayjs(d2).utcOffset(5, true).format()) .toBe(moment(d2).utcOffset(5, true).format()) }) test('UTC mode', () => { const d = dayjs.utc('2000-01-01T06:00:00Z') expect(d.isUTC()).toBeTruthy() expect(d.utcOffset(0).isUTC()).toBeTruthy() expect(d.utcOffset(1).isUTC()).toBeFalsy() }) test('change hours when changing the utc offset in UTC mode', () => { const d = dayjs.utc('2000-01-01T06:31:00Z') expect(d.hour()).toBe(6) expect(d.utcOffset(0).hour()).toBe(6) expect(d.utcOffset(-60).hour()).toBe(5) expect(d.utcOffset(60).hour()).toBe(7) expect(d.utcOffset(-30).format('HH:mm')).toBe('06:01') expect(d.utcOffset(30).format('HH:mm')).toBe('07:01') expect(d.utcOffset(-1380).format('HH:mm')).toBe('07:31') }) test('correctly set and add hours in offset mode', () => { const d10 = dayjs('2000-01-30T06:31:00+10:00').utcOffset(10) const dm8 = dayjs('2000-01-30T06:31:00-08:00').utcOffset(-8) expect(d10.hour(5).hour()).toBe(5) expect(d10.hour(5).add(1, 'hour').hour()).toBe(6) expect(d10.hour(5).add(-10, 'hour').hour()).toBe(19) expect(dm8.hour(5).hour()).toBe(5) expect(dm8.hour(5).add(1, 'hour').hour()).toBe(6) expect(dm8.hour(5).add(-10, 'hour').hour()).toBe(19) }) test('keep hours when adding month in offset mode', () => { const d10 = dayjs('2000-01-30T06:31:00+10:00').utcOffset(10) const dm8 = dayjs('2000-01-30T06:31:00-08:00').utcOffset(-8) expect(d10.add(1, 'month').hour()).toBe(6) expect(dm8.add(1, 'month').hour()).toBe(6) expect(d10.add(-2, 'month').hour()).toBe(6) expect(dm8.add(-2, 'month').hour()).toBe(6) }) test('utc costrustor', () => { const d = new Date(2019, 8, 11, 0, 0, 0).getTime() expect(moment(d).utc().utcOffset(480).valueOf()) .toBe(dayjs(d).utc().utcOffset(480).valueOf()) expect(moment(d).utc().local() .utcOffset(480) .valueOf()) .toBe(dayjs(d).utc().local() .utcOffset(480) .valueOf()) }) test('utc startOf', () => { const d = new Date(2019, 8, 11, 0, 0, 0, 0).getTime() expect(moment(d).utc().utcOffset(480).endOf('day') .valueOf()) .toBe(dayjs(d).utc().utcOffset(480).endOf('day') .valueOf()) expect(moment(d).utc().utcOffset(480).endOf('day') .valueOf()) .toBe(dayjs(d).utc().utcOffset(480).endOf('day') .valueOf()) const d2 = '2017-07-20T11:00:00+00:00' const d2d = dayjs(d2).utcOffset(-12).startOf('day').valueOf() const d2m = moment(d2).utcOffset(-12).startOf('day').valueOf() expect(d2d) .toBe(d2m) expect(d2d) .toBe(1500465600000) }) test('cloning dates modified with utcOffset', () => { const djs = dayjs('2023-10-29T00:00:00+03:00') const tests = [ djs, djs.utcOffset(-240), djs.utcOffset(-240, true), djs.utcOffset(120), djs.utcOffset(120, true), djs.utcOffset(0), djs.utcOffset(0, true) ] tests.forEach((d) => { expect(dayjs(d).format()).toEqual(d.format()) }) }) ================================================ FILE: test/plugin/utc.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import customParseFormat from '../../src/plugin/customParseFormat' import utc from '../../src/plugin/utc' dayjs.extend(utc) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('UTC Get', () => { it('UTC Year', () => { expect(dayjs().utc().year()).toBe(moment().utc().year()) }) it('UTC Month', () => { expect(dayjs().utc().month()).toBe(moment().utc().month()) }) it('UTC Day of Week', () => { expect(dayjs().utc().day()).toBe(moment().utc().day()) }) it('UTC Date', () => { expect(dayjs().utc().date()).toBe(moment().utc().date()) }) it('UTC Hour', () => { expect(dayjs().utc().hour()).toBe(moment().utc().hour()) }) it('UTC Minute', () => { expect(dayjs().utc().minute()).toBe(moment().utc().minute()) }) it('UTC Second', () => { expect(dayjs().utc().second()).toBe(moment().utc().second()) }) it('UTC Millisecond', () => { expect(dayjs().utc().millisecond()).toBe(moment().utc().millisecond()) }) }) describe('Parse UTC ', () => { it('Parse Now', () => { expect(dayjs.utc().format()).toBe(moment.utc().format()) expect(dayjs().utc().format()).toBe(moment().utc().format()) }) it('Parse date string without timezone', () => { const d = '2018-09-06' expect(dayjs.utc(d).format()).toEqual(moment.utc(d).format()) expect(dayjs.utc(d).format()).toEqual('2018-09-06T00:00:00Z') expect(dayjs(d).utc().format()).toEqual(moment(d).utc().format()) const d2 = '2018-09' expect(dayjs.utc(d2).format()).toEqual(moment.utc(d2).format()) expect(dayjs.utc(d2).format()).toEqual('2018-09-01T00:00:00Z') expect(dayjs(d2).utc().format()).toEqual(moment(d2).utc().format()) const d3 = '2018' expect(dayjs.utc(d3).format()).toEqual(moment.utc(d3).format()) expect(dayjs.utc(d3).format()).toEqual('2018-01-01T00:00:00Z') expect(dayjs(d3).utc().format()).toEqual(moment(d3).utc().format()) }) it('creating with utc with timezone', () => { const d = '2011-02-02T03:04:05+00:00' expect(dayjs.utc(d).format()).toEqual(moment.utc(d).format()) const d2 = '2012-01-02T08:20:00+09:00' expect(dayjs.utc(d2).format()).toEqual(moment.utc(d2).format()) }) it('Parse date string without timezone', () => { const d = '2017-04-22 19:50:16' expect(dayjs.utc(d).format()).toEqual('2017-04-22T19:50:16Z') expect(dayjs.utc(d).format()).toEqual(moment.utc(d).format()) expect(dayjs(d).utc().format()).toBe(moment(d).utc().format()) const d2 = '2012-01-02T08:20:00' expect(dayjs.utc(d2).format()).toEqual(moment.utc(d2).format()) }) it('Parse date string set utc in config', () => { const d = '2018-09-06T19:34:28Z' expect(dayjs(d, { utc: true }).format()).toEqual('2018-09-06T19:34:28Z') expect(dayjs(d, { utc: true }).format()).toEqual(moment(d).utc().format()) expect(dayjs(d).utc().format()).toEqual('2018-09-06T19:34:28Z') expect(dayjs(d).utc().format()).toEqual(moment(d).utc().format()) expect(dayjs.utc(d).format()).toEqual('2018-09-06T19:34:28Z') expect(dayjs.utc(d).format()).toEqual(moment.utc(d).format()) }) it('parses unlimited millisecond in utc', () => { const date = '2019-03-25T06:41:00.999999999' const ds = dayjs.utc(date) const ms = moment.utc(date) expect(ds.valueOf()).toEqual(ms.valueOf()) expect(ds.millisecond()).toEqual(ms.millisecond()) }) }) it('Clone retains the UTC mode', () => { const instance = dayjs('2018-09-06').utc() const another = instance.clone() expect(another.$u).toBeTruthy() }) it('UTC mode format tokens', () => { const d = '2018-09-06T19:34:28.657Z' const instance = dayjs(d).utc() const format = 'HH-hh-mm-ss-SSS-Z-ZZ' expect(instance.format(format)).toBe('19-07-34-28-657-+00:00-+0000') expect(instance.format(format)).toBe(moment.utc(d).format(format)) }) describe('local', () => { it('Returns a new instance', () => { const instance = dayjs.utc('2018-09-06T19:34:28.657Z') const local = instance.local() expect(local).not.toBe(instance) }) it('UTC to local', () => { const d = '2018-09-06' expect(dayjs.utc(d).local().format()).toEqual(moment.utc(d).local().format()) }) }) it('StartOf EndOf Year ... in UTC mode', () => { const testArr = ['year', 'month', 'day', 'date', 'week', 'hour', 'minute', 'second'] testArr.forEach((d) => { expect(dayjs().utc().startOf(d).format()).toBe(moment().utc().startOf(d).format()) expect(dayjs().utc().endOf(d).format()).toBe(moment().utc().endOf(d).format()) }) }) describe('UTC Set', () => { it('Set UTC Day', () => { expect(dayjs().utc().set('date', 30).valueOf()).toBe(moment().utc().set('date', 30).valueOf()) }) it('Set UTC Day of Week', () => { expect(dayjs().utc().set('day', 0).valueOf()).toBe(moment().utc().set('day', 0).valueOf()) }) it('Set UTC Month', () => { expect(dayjs().utc().set('month', 11).valueOf()).toBe(moment().utc().set('month', 11).valueOf()) }) it('Set UTC Year', () => { expect(dayjs().utc().set('year', 2008).valueOf()).toBe(moment().utc().set('year', 2008).valueOf()) }) it('Set UTC Hour', () => { expect(dayjs().utc().set('hour', 6).valueOf()).toBe(moment().utc().set('hour', 6).valueOf()) }) it('Set UTC Minute', () => { expect(dayjs().utc().set('minute', 59).valueOf()).toBe(moment().utc().set('minute', 59).valueOf()) }) it('Set UTC Second', () => { expect(dayjs().utc().set('second', 59).valueOf()).toBe(moment().utc().set('second', 59).valueOf()) }) it('Set UTC Millisecond', () => { expect(dayjs().utc().set('millisecond', 999).valueOf()).toBe(moment().utc().set('millisecond', 999).valueOf()) }) }) it('isUTC', () => { expect(dayjs().isUTC()).toBe(false) expect(dayjs().utc().isUTC()).toBe(true) expect(dayjs.utc().isUTC()).toBe(true) }) describe('UTC and local', () => { const localDay = dayjs(Date.UTC(2011, 1, 2, 3, 4, 5, 6)) const utcDay = localDay.utc() it('utc', () => { expect(utcDay.date()).toBe(2) expect(utcDay.day()).toBe(3) expect(utcDay.hour()).toBe(3) }) const localAnainDay = utcDay.local() it('local', () => { if (localAnainDay.utcOffset() < -180) { expect(localAnainDay.date()).toBe(1) expect(localAnainDay.day()).toBe(2) } else { expect(localAnainDay.date()).toBe(2) expect(localAnainDay.day()).toBe(3) } }) const offset = Math.floor(localAnainDay.utcOffset() / 60) const expected = (24 + 3 + offset) % 24 it('utcOffset', () => { expect(localAnainDay.hour()).toBe(expected) expect(dayjs().utc().utcOffset()).toBe(0) }) }) describe('UTC with customParseFormat', () => { it('Custom Parse Format', () => { dayjs.extend(customParseFormat) const instant = dayjs.utc('2011-02-02 03:04:05', 'YYYY-MM-DD HH:mm:ss') const momentInstant = moment.utc('2011-02-02 03:04:05', 'YYYY-MM-DD HH:mm:ss') expect(instant.date()).toBe(2) expect(instant.hour()).toBe(3) expect(instant.format()).toBe('2011-02-02T03:04:05Z') expect(instant.format()).toBe(momentInstant.format()) }) }) describe('UTC Offset', () => { it('get utcOffset', () => { expect(dayjs().utcOffset()).toBe(moment().utcOffset()) expect(dayjs().utc().utcOffset()).toBe(moment().utc().utcOffset()) }) it('get utc offset with a number value', () => { const time = '2021-02-28 19:40:10' const hoursOffset = -8 const daysJS = dayjs(time).utc().utcOffset(hoursOffset * 60, true) const momentJS = moment(time).utc(true).utcOffset(hoursOffset, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(hoursOffset * 60) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with a negative valid string value, format: HH:mm', () => { const time = '2021-02-28 19:40:10' const hoursOffset = -8 const daysJS = dayjs(time).utc().utcOffset(`-0${Math.abs(hoursOffset)}:00`, true) const momentJS = moment(time).utc(true).utcOffset(`-0${Math.abs(hoursOffset)}:00`, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(hoursOffset * 60) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with a positive valid string value, format: HH:mm', () => { const time = '2021-02-28 19:40:10' const hoursOffset = 8 const daysJS = dayjs(time).utc().utcOffset(`+0${hoursOffset}:00`, true) const momentJS = moment(time).utc(true).utcOffset(`+0${hoursOffset}:00`, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(hoursOffset * 60) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with a negative valid string value, format: HHmm', () => { const time = '2021-02-28 19:40:10' const hoursOffset = -8 const daysJS = dayjs(time).utc().utcOffset(`-0${Math.abs(hoursOffset)}00`, true) const momentJS = moment(time).utc(true).utcOffset(`-0${Math.abs(hoursOffset)}00`, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(hoursOffset * 60) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with a positive valid string value, format: HHmm', () => { const time = '2021-02-28 19:40:10' const hoursOffset = 8 const daysJS = dayjs(time).utc().utcOffset(`+0${hoursOffset}00`, true) const momentJS = moment(time).utc(true).utcOffset(`+0${hoursOffset}00`, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(hoursOffset * 60) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with an invalid string value, value: random', () => { const time = '2021-02-28 19:40:10' const daysJS = dayjs(time, { utc: true }).utc(true).utcOffset('random') const momentJS = moment(time).utc(true).utcOffset('random') expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(0) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) it('get utc offset with an invalid string value, value: 0', () => { const time = '2021-02-28 19:40:10' const daysJS = dayjs(time, { utc: true }).utc(true).utcOffset('+0000') const momentJS = moment(time).utc(true).utcOffset('+0000') expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) expect(daysJS.utcOffset()).toEqual(0) expect(daysJS.utcOffset()).toEqual(momentJS.utcOffset()) }) }) describe('Diff', () => { const d1 = '2021-06-07' const d2 = '2021-06-06' it('utc.diff(utc)', () => { [dayjs, moment].forEach((_) => { expect(_.utc(d1).diff(_.utc(d2), 'days')).toBe(1) expect(_.utc(d1).diff(_.utc(d2), 'm')).toBe(1440) }) }) it('default diff', () => { expect(dayjs().diff()).toBeDefined() }) it('local.diff(utc)', () => { expect(dayjs(d1).diff(dayjs.utc(d2), 'days')) .toBe(moment(d1).diff(moment.utc(d2), 'days')) expect(dayjs(d1).diff(dayjs.utc(d2), 'm')) .toBe(moment(d1).diff(moment.utc(d2), 'm')) }) it('utc.diff(local)', () => { expect(dayjs.utc(d1).diff(d2, 'days')) .toBe(moment.utc(d1).diff(d2, 'days')) expect(dayjs.utc(d1).diff(d2, 'm')) .toBe(moment.utc(d1).diff(d2, 'm')) }) }) it('utc keepLocalTime', () => { const t = '2016-05-03 22:15:01' const d = dayjs(t).utc(true) const m = moment(t).utc(true) const fd = d.format() const dd = d.toDate() const vd = d.valueOf() const fm = m.format() const dm = m.toDate() const vm = m.valueOf() expect(fd).toEqual(fm) expect(fd).toEqual('2016-05-03T22:15:01Z') expect(dd).toEqual(dm) expect(vd).toEqual(vm) }) it('utc diff undefined edge case', () => { expect(dayjs().diff(undefined, 'seconds')).toBeDefined() }) ================================================ FILE: test/plugin/weekOfYear.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import weekOfYear from '../../src/plugin/weekOfYear' import advancedFormat from '../../src/plugin/advancedFormat' import '../../src/locale/en-gb' dayjs.extend(advancedFormat) dayjs.extend(weekOfYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Week of year', () => { dayjs.locale('en') const day = '2018-12-31T10:59:09+08:00' const week = 27 expect(dayjs(day).week()).toBe(moment(day).week()) expect(dayjs().week()).toBe(moment().week()) expect(dayjs().week(week).week()).toBe(moment().week(week).week()) expect(dayjs().weeks(week).week()).toBe(moment().weeks(week).week()) expect(dayjs().weeks(-week).week()).toBe(moment().weeks(-week).week()) expect(dayjs().weeks(55).week()).toBe(moment().weeks(55).week()) expect(dayjs().weeks()).toBe(moment().weeks()) }) it('Week of year with locale', () => { dayjs.locale('en-gb') moment.locale('en-gb') const day = '2019-07-28' expect(dayjs(day).week()).toBe(moment(day).week()) }) describe('Week of year with locale edges', () => { const testCases = [ '2018-12-30', '2018-12-31', '2019-12-29', '2019-12-30', '2016-01-01', '2016-01-04' ] testCases.forEach((t) => { it(`Edges ${t}`, () => { expect(dayjs(t).week()) .toBe(moment(t).week()) }) }) }) it('Format w ww wo', () => { const day = '2019-07-28' const D = dayjs(day) const M = moment(day) expect(D.format('w ww wo')).toBe(M.format('w ww wo')) }) ================================================ FILE: test/plugin/weekYear.test.js ================================================ import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import weekYear from '../../src/plugin/weekYear' import weekOfYear from '../../src/plugin/weekOfYear' import '../../src/locale/en-gb' dayjs.extend(weekYear) dayjs.extend(weekOfYear) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Week Year', () => { const daySet = [ ['2018-12-01', 2018], ['2018-12-30', 2019], ['2018-12-31', 2019], ['2019-01-01', 2019] ] daySet.forEach((d) => { const [day, result] = d const dResult = dayjs(day).weekYear() expect(dResult).toBe(result) expect(dResult).toBe(moment(day).weekYear()) }) }) it('yearStart: 4', () => { const daySet = [ ['2020-12-31', 2020], ['2021-01-01', 2020], ['2021-01-02', 2020], ['2021-01-03', 2020], ['2021-01-04', 2021], ['2021-01-05', 2021] ] daySet.forEach((d) => { const [day, result] = d const dResult = dayjs(day).locale('en-gb').weekYear() expect(dResult).toBe(result) expect(dResult).toBe(moment(day).locale('en-gb').weekYear()) }) }) ================================================ FILE: test/plugin/weekday.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import weekday from '../../src/plugin/weekday' import '../../src/locale/zh-cn' import '../../src/locale/ar' dayjs.extend(weekday) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() moment.locale('en') dayjs.locale('en') }) it('Sunday is the first day of the week', () => { expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).format()).toBe(moment().weekday(-7).format()) expect(dayjs().weekday(7).format()).toBe(moment().weekday(7).format()) }) it('Monday is the first day of the week', () => { moment.locale('zh-cn') dayjs.locale('zh-cn') expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).format()).toBe(moment().weekday(-7).format()) expect(dayjs().weekday(7).format()).toBe(moment().weekday(7).format()) const d1 = '2020-01-05' expect(dayjs(d1).weekday()).toBe(moment(d1).weekday()) const d2 = '2020-01-07' expect(dayjs(d2).weekday()).toBe(moment(d2).weekday()) }) it('Saturday is the first day of the week', () => { moment.locale('ar') dayjs.locale('ar') expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).valueOf()).toBe(moment().weekday(-7).valueOf()) expect(dayjs().weekday(7).valueOf()).toBe(moment().weekday(7).valueOf()) }) ================================================ FILE: test/plugin.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../src' const testPlugin = (o, c, d) => { c.prototype.newApi = () => ('hello world') d.newFunc = () => ('hi world') } const testPluginWithConfig = (o, c) => { c.prototype.newApiWithConfig = () => (`hello world ${o || ''}`) } dayjs.extend(testPlugin) dayjs.extend(testPluginWithConfig, 'good') beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Plugin extend method and option', () => { expect(dayjs().newApi()).toBe('hello world') expect(dayjs().newApiWithConfig()).toBe('hello world good') }) it('Plugin extend dayjs', () => { expect(dayjs.newFunc()).toBe('hi world') }) it('Plugin use core utils', () => { // u => isUndefined expect(dayjs().$utils().u).toBeInstanceOf(Function) }) ================================================ FILE: test/query.test.js ================================================ import MockDate from 'mockdate' import dayjs from '../src' beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) describe('Is Before Is After Is Same', () => { it('Compare to dayjs object', () => { const dayA = dayjs() const dayB = dayA.clone().add(1, 'day') const dayC = dayA.clone().subtract(1, 'day') expect(dayC.isBefore(dayA)).toBe(true) expect(dayA.isSame(dayjs())).toBe(true) expect(dayB.isAfter(dayA)).toBe(true) expect(dayA.isSame()).toBe(true) expect(dayB.isAfter()).toBe(true) expect(dayC.isBefore()).toBe(true) }) it('No value', () => { const dayA = dayjs() const dayB = dayA.clone().add(1, 'day') const dayC = dayA.clone().subtract(1, 'day') expect(dayA.isSame()).toBe(true) expect(dayB.isAfter()).toBe(true) expect(dayC.isBefore()).toBe(true) }) it('With string', () => { const dayD = dayjs() expect(dayD.isSame('20180101')).toBe(false) expect(dayD.isAfter('20180101')).toBe(true) expect(dayD.isBefore('20180101')).toBe(false) }) }) ================================================ FILE: test/timezone.test.js ================================================ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../src' import timezone from '../src/plugin/timezone' import utc from '../src/plugin/utc' dayjs.extend(utc) dayjs.extend(timezone) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Add Time days (DST)', () => { // change timezone before running test // New Zealand (-720) expect(dayjs('2018-04-01').add(1, 'd').format()).toBe(moment('2018-04-01').add(1, 'd').format()) expect(dayjs('2018-03-28').add(1, 'w').format()).toBe(moment('2018-03-28').add(1, 'w').format()) // London (-60) expect(dayjs('2018-10-28').add(1, 'd').format()).toBe(moment('2018-10-28').add(1, 'd').format()) expect(dayjs('2018-10-26').add(1, 'w').format()).toBe(moment('2018-10-26').add(1, 'w').format()) }) it('Utc Offset', () => { expect(dayjs().utcOffset()).toBe(moment().utcOffset()) }) it('Diff (DST)', () => { const day = '2018-10-28' const dayjsA = dayjs(day) const dayjsB = dayjs(day).add(-1000, 'days') const momentA = moment(day) const momentB = moment(day).add(-1000, 'days') const units = ['seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'quarters', 'years'] units.forEach((unit) => { expect(dayjsA.diff(dayjsB, unit)).toBe(momentA.diff(momentB, unit)) expect(dayjsA.diff(dayjsB, unit, true)).toBe(momentA.diff(momentB, unit, true)) }) }) it('UTC add day in DST', () => { const testDate = '2019-03-10' const dayTest = dayjs(testDate) .utc() .startOf('day') const momentTest = moment(testDate) .utc() .startOf('day') expect(dayTest.add(1, 'day').format()) .toBe(momentTest.clone().add(1, 'day').format()) expect(dayTest.add(2, 'day').format()) .toBe(momentTest.clone().add(2, 'day').format()) }) it('UTC and utcOffset', () => { const test1 = 1331449199000 // 2012/3/11 06:59:59 GMT+0000 expect(dayjs(test1).utcOffset(-300).format()) .toBe(moment(test1).utcOffset(-300).format()) const test2 = '2000-01-01T06:31:00Z' expect(dayjs.utc(test2).utcOffset(-60).format()) .toBe(moment.utc(test2).utcOffset(-60).format()) // across DST, copied from utc.test.js#get utc offset with a number value const time = '2021-02-28 19:40:10' const hoursOffset = -8 const daysJS = dayjs(time).utc().utcOffset(hoursOffset * 60, true) const momentJS = moment(time).utc(true).utcOffset(hoursOffset, true) expect(daysJS.toISOString()).toEqual(momentJS.toISOString()) }) it('UTC diff in DST', () => { // DST till 2020-10-25 const day1 = dayjs.utc('20201023') // in DST const day2 = dayjs.utc('20201026') expect(day1.diff(day2, 'd')) .toBe(-3) }) ================================================ FILE: test/utils.test.js ================================================ import Utils from '../src/utils' const prettyUnit = Utils.p const padStart = Utils.s const padZoneStr = Utils.z it('PrettyUnit', () => { expect(prettyUnit('Days')).toBe('day') expect(prettyUnit('days')).toBe('day') expect(prettyUnit('day')).toBe('day') expect(prettyUnit('quarter')).toBe('quarter') expect(prettyUnit('quarters')).toBe('quarter') expect(prettyUnit('D')).toBe('date') expect(prettyUnit('d')).toBe('day') expect(prettyUnit('M')).toBe('month') expect(prettyUnit('y')).toBe('year') expect(prettyUnit('h')).toBe('hour') expect(prettyUnit('m')).toBe('minute') expect(prettyUnit('s')).toBe('second') expect(prettyUnit('ms')).toBe('millisecond') expect(prettyUnit('Q')).toBe('quarter') expect(prettyUnit()).toBe('') }) it('PadZoneStr', () => { const instance = {} instance.utcOffset = () => 0 * -1 expect(padZoneStr(instance)).toBe('+00:00') instance.utcOffset = () => 1 * 60 * -1 expect(padZoneStr(instance)).toBe('-01:00') instance.utcOffset = () => -1 * 60 * -1 expect(padZoneStr(instance)).toBe('+01:00') instance.utcOffset = () => -10 * 60 * -1 expect(padZoneStr(instance)).toBe('+10:00') instance.utcOffset = () => 10 * 60 * -1 expect(padZoneStr(instance)).toBe('-10:00') instance.utcOffset = () => ((-5 * 60) - 30) * -1 expect(padZoneStr(instance)).toBe('+05:30') }) it('PadStart', () => { expect(padStart(1, 2, '0')).toBe('01') expect(padStart(0, 2, '0')).toBe('00') }) ================================================ FILE: types/index.d.ts ================================================ /// export = dayjs; declare function dayjs (date?: dayjs.ConfigType): dayjs.Dayjs declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, strict?: boolean): dayjs.Dayjs declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean): dayjs.Dayjs declare namespace dayjs { interface ConfigTypeMap { default: string | number | Date | Dayjs | null | undefined } export type ConfigType = ConfigTypeMap[keyof ConfigTypeMap] export interface FormatObject { locale?: string, format?: string, utc?: boolean } export type OptionType = FormatObject | string | string[] export type UnitTypeShort = 'd' | 'D' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' export type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' export type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates' export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort; export type OpUnitType = UnitType | "week" | "weeks" | 'w'; export type QUnitType = UnitType | "quarter" | "quarters" | 'Q'; export type ManipulateType = Exclude; class Dayjs { constructor (config?: ConfigType) /** * All Day.js objects are immutable. Still, `dayjs#clone` can create a clone of the current object if you need one. * ``` * dayjs().clone()// => Dayjs * dayjs(dayjs('2019-01-25')) // passing a Dayjs object to a constructor will also clone it * ``` * Docs: https://day.js.org/docs/en/parse/dayjs-clone */ clone(): Dayjs /** * This returns a `boolean` indicating whether the Day.js object contains a valid date or not. * ``` * dayjs().isValid()// => boolean * ``` * Docs: https://day.js.org/docs/en/parse/is-valid */ isValid(): boolean /** * Get the year. * ``` * dayjs().year()// => 2020 * ``` * Docs: https://day.js.org/docs/en/get-set/year */ year(): number /** * Set the year. * ``` * dayjs().year(2000)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/year */ year(value: number): Dayjs /** * Get the month. * * Months are zero indexed, so January is month 0. * ``` * dayjs().month()// => 0-11 * ``` * Docs: https://day.js.org/docs/en/get-set/month */ month(): number /** * Set the month. * * Months are zero indexed, so January is month 0. * * Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the next year. * ``` * dayjs().month(0)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/month */ month(value: number): Dayjs /** * Get the date of the month. * ``` * dayjs().date()// => 1-31 * ``` * Docs: https://day.js.org/docs/en/get-set/date */ date(): number /** * Set the date of the month. * * Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the next months. * ``` * dayjs().date(1)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/date */ date(value: number): Dayjs /** * Get the day of the week. * * Returns numbers from 0 (Sunday) to 6 (Saturday). * ``` * dayjs().day()// 0-6 * ``` * Docs: https://day.js.org/docs/en/get-set/day */ day(): 0 | 1 | 2 | 3 | 4 | 5 | 6 /** * Set the day of the week. * * Accepts numbers from 0 (Sunday) to 6 (Saturday). If the range is exceeded, it will bubble up to next weeks. * ``` * dayjs().day(0)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/day */ day(value: number): Dayjs /** * Get the hour. * ``` * dayjs().hour()// => 0-23 * ``` * Docs: https://day.js.org/docs/en/get-set/hour */ hour(): number /** * Set the hour. * * Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the next day. * ``` * dayjs().hour(12)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/hour */ hour(value: number): Dayjs /** * Get the minutes. * ``` * dayjs().minute()// => 0-59 * ``` * Docs: https://day.js.org/docs/en/get-set/minute */ minute(): number /** * Set the minutes. * * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next hour. * ``` * dayjs().minute(59)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/minute */ minute(value: number): Dayjs /** * Get the seconds. * ``` * dayjs().second()// => 0-59 * ``` * Docs: https://day.js.org/docs/en/get-set/second */ second(): number /** * Set the seconds. * * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next minutes. * ``` * dayjs().second(1)// Dayjs * ``` */ second(value: number): Dayjs /** * Get the milliseconds. * ``` * dayjs().millisecond()// => 0-999 * ``` * Docs: https://day.js.org/docs/en/get-set/millisecond */ millisecond(): number /** * Set the milliseconds. * * Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the next seconds. * ``` * dayjs().millisecond(1)// => Dayjs * ``` * Docs: https://day.js.org/docs/en/get-set/millisecond */ millisecond(value: number): Dayjs /** * Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes. * * In general: * ``` * dayjs().set(unit, value) === dayjs()[unit](value) * ``` * Units are case insensitive, and support plural and short forms. * ``` * dayjs().set('date', 1) * dayjs().set('month', 3) // April * dayjs().set('second', 30) * ``` * Docs: https://day.js.org/docs/en/get-set/set */ set(unit: UnitType, value: number): Dayjs /** * String getter, returns the corresponding information getting from Day.js object. * * In general: * ``` * dayjs().get(unit) === dayjs()[unit]() * ``` * Units are case insensitive, and support plural and short forms. * ``` * dayjs().get('year') * dayjs().get('month') // start 0 * dayjs().get('date') * ``` * Docs: https://day.js.org/docs/en/get-set/get */ get(unit: UnitType): number /** * Returns a cloned Day.js object with a specified amount of time added. * ``` * dayjs().add(7, 'day')// => Dayjs * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/manipulate/add */ add(value: number, unit?: ManipulateType): Dayjs /** * Returns a cloned Day.js object with a specified amount of time subtracted. * ``` * dayjs().subtract(7, 'year')// => Dayjs * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/manipulate/subtract */ subtract(value: number, unit?: ManipulateType): Dayjs /** * Returns a cloned Day.js object and set it to the start of a unit of time. * ``` * dayjs().startOf('year')// => Dayjs * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/manipulate/start-of */ startOf(unit: OpUnitType): Dayjs /** * Returns a cloned Day.js object and set it to the end of a unit of time. * ``` * dayjs().endOf('month')// => Dayjs * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/manipulate/end-of */ endOf(unit: OpUnitType): Dayjs /** * Get the formatted date according to the string of tokens passed in. * * To escape characters, wrap them in square brackets (e.g. [MM]). * ``` * dayjs().format()// => current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00' * dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')// 'YYYYescape 2019-01-25T00:00:00-02:00Z' * dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019' * ``` * Docs: https://day.js.org/docs/en/display/format */ format(template?: string): string /** * This indicates the difference between two date-time in the specified unit. * * To get the difference in milliseconds, use `dayjs#diff` * ``` * const date1 = dayjs('2019-01-25') * const date2 = dayjs('2018-06-05') * date1.diff(date2) // 20214000000 default milliseconds * date1.diff() // milliseconds to current time * ``` * * To get the difference in another unit of measurement, pass that measurement as the second argument. * ``` * const date1 = dayjs('2019-01-25') * date1.diff('2018-06-05', 'month') // 7 * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/display/difference */ diff(date?: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number /** * This returns the number of **milliseconds** since the Unix Epoch of the Day.js object. * ``` * dayjs('2019-01-25').valueOf() // 1548381600000 * +dayjs(1548381600000) // 1548381600000 * ``` * To get a Unix timestamp (the number of seconds since the epoch) from a Day.js object, you should use Unix Timestamp `dayjs#unix()`. * * Docs: https://day.js.org/docs/en/display/unix-timestamp-milliseconds */ valueOf(): number /** * This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object. * ``` * dayjs('2019-01-25').unix() // 1548381600 * ``` * This value is floored to the nearest second, and does not include a milliseconds component. * * Docs: https://day.js.org/docs/en/display/unix-timestamp */ unix(): number /** * Get the number of days in the current month. * ``` * dayjs('2019-01-25').daysInMonth() // 31 * ``` * Docs: https://day.js.org/docs/en/display/days-in-month */ daysInMonth(): number /** * To get a copy of the native `Date` object parsed from the Day.js object use `dayjs#toDate`. * ``` * dayjs('2019-01-25').toDate()// => Date * ``` */ toDate(): Date /** * To serialize as an ISO 8601 string. * ``` * dayjs('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z' * ``` * Docs: https://day.js.org/docs/en/display/as-json */ toJSON(): string /** * To format as an ISO 8601 string. * ``` * dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z' * ``` * Docs: https://day.js.org/docs/en/display/as-iso-string */ toISOString(): string /** * Returns a string representation of the date. * ``` * dayjs('2019-01-25').toString() // 'Fri, 25 Jan 2019 02:00:00 GMT' * ``` * Docs: https://day.js.org/docs/en/display/as-string */ toString(): string /** * Get the UTC offset in minutes. * ``` * dayjs().utcOffset() * ``` * Docs: https://day.js.org/docs/en/manipulate/utc-offset */ utcOffset(): number /** * This indicates whether the Day.js object is before the other supplied date-time. * ``` * dayjs().isBefore(dayjs('2011-01-01')) // default milliseconds * ``` * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. * ``` * dayjs().isBefore('2011-01-01', 'year')// => boolean * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/query/is-before */ isBefore(date?: ConfigType, unit?: OpUnitType): boolean /** * This indicates whether the Day.js object is the same as the other supplied date-time. * ``` * dayjs().isSame(dayjs('2011-01-01')) // default milliseconds * ``` * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. * ``` * dayjs().isSame('2011-01-01', 'year')// => boolean * ``` * Docs: https://day.js.org/docs/en/query/is-same */ isSame(date?: ConfigType, unit?: OpUnitType): boolean /** * This indicates whether the Day.js object is after the other supplied date-time. * ``` * dayjs().isAfter(dayjs('2011-01-01')) // default milliseconds * ``` * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. * ``` * dayjs().isAfter('2011-01-01', 'year')// => boolean * ``` * Units are case insensitive, and support plural and short forms. * * Docs: https://day.js.org/docs/en/query/is-after */ isAfter(date?: ConfigType, unit?: OpUnitType): boolean locale(): string locale(preset: string | ILocale, object?: Partial): Dayjs } export type PluginFunc = (option: T, c: typeof Dayjs, d: typeof dayjs) => void export function extend(plugin: PluginFunc, option?: T): Dayjs export function locale(preset?: string | ILocale, object?: Partial, isLocal?: boolean): string export function isDayjs(d: any): d is Dayjs export function unix(t: number): Dayjs const Ls : { [key: string] : ILocale } } ================================================ FILE: types/locale/index.d.ts ================================================ /// declare module 'dayjs/locale/*' { namespace locale { interface Locale extends ILocale {} } const locale: locale.Locale export = locale } ================================================ FILE: types/locale/types.d.ts ================================================ declare interface ILocale { name: string weekdays?: string[] months?: string[] weekStart?: number weekdaysShort?: string[] monthsShort?: string[] weekdaysMin?: string[] ordinal?: (n: number) => number | string formats: Partial<{ LT: string LTS: string L: string LL: string LLL: string LLLL: string }> relativeTime: Partial<{ future: string past: string s: string m: string mm: string h: string hh: string d: string dd: string M: string MM: string y: string yy: string }> } ================================================ FILE: types/plugin/advancedFormat.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/arraySupport.d.ts ================================================ import { PluginFunc } from 'dayjs' declare module 'dayjs' { interface ConfigTypeMap { arraySupport: [number?, number?, number?, number?, number?, number?, number?] } } declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/badMutable.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/bigIntSupport.d.ts ================================================ import { PluginFunc } from 'dayjs' declare module 'dayjs' { interface ConfigTypeMap { bigIntSupport: BigInt } export function unix(t: BigInt): Dayjs } declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/buddhistEra.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/calendar.d.ts ================================================ import { PluginFunc, ConfigType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { calendar(referenceTime?: ConfigType, formats?: object): string } } ================================================ FILE: types/plugin/customParseFormat.d.ts ================================================ import { PluginFunc } from 'dayjs' declare interface PluginOptions { parseTwoDigitYear?: (yearString: string) => number } declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/dayOfYear.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { dayOfYear(): number dayOfYear(value: number): Dayjs } } ================================================ FILE: types/plugin/devHelper.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/duration.d.ts ================================================ import { PluginFunc } from 'dayjs' import { OpUnitType, UnitTypeLongPlural } from 'dayjs'; declare const plugin: PluginFunc export as namespace plugin; export = plugin declare namespace plugin { /** * @deprecated Please use more strict types */ type DurationInputType = string | number | object /** * @deprecated Please use more strict types */ type DurationAddType = number | object | Duration type DurationUnitsObjectType = Partial<{ [unit in Exclude | "weeks"]: number }>; type DurationUnitType = Exclude type CreateDurationType = ((units: DurationUnitsObjectType) => Duration) & ((time: number, unit?: DurationUnitType) => Duration) & ((ISO_8601: string) => Duration) type AddDurationType = CreateDurationType & ((duration: Duration) => Duration) interface Duration { new (input: string | number | object, unit?: string, locale?: string): Duration clone(): Duration humanize(withSuffix?: boolean): string milliseconds(): number asMilliseconds(): number seconds(): number asSeconds(): number minutes(): number asMinutes(): number hours(): number asHours(): number days(): number asDays(): number weeks(): number asWeeks(): number months(): number asMonths(): number years(): number asYears(): number as(unit: DurationUnitType): number get(unit: DurationUnitType): number add: AddDurationType subtract: AddDurationType toJSON(): string toISOString(): string format(formatStr?: string): string locale(locale: string): Duration } } declare module 'dayjs' { interface Dayjs { add(duration: plugin.Duration): Dayjs subtract(duration: plugin.Duration): Dayjs } /** * @param time If unit is not present, time treated as number of milliseconds */ export const duration: plugin.CreateDurationType; export function isDuration(d: any): d is plugin.Duration } ================================================ FILE: types/plugin/isBetween.d.ts ================================================ import { PluginFunc, ConfigType, OpUnitType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isBetween(a: ConfigType, b: ConfigType, c?: OpUnitType | null, d?: '()' | '[]' | '[)' | '(]'): boolean } } ================================================ FILE: types/plugin/isLeapYear.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isLeapYear(): boolean } } ================================================ FILE: types/plugin/isMoment.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { export function isMoment(input: any): boolean } ================================================ FILE: types/plugin/isSameOrAfter.d.ts ================================================ import { PluginFunc, ConfigType, OpUnitType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isSameOrAfter(date?: ConfigType, unit?: OpUnitType): boolean } } ================================================ FILE: types/plugin/isSameOrBefore.d.ts ================================================ import { PluginFunc, ConfigType, OpUnitType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isSameOrBefore(date?: ConfigType, unit?: OpUnitType): boolean } } ================================================ FILE: types/plugin/isToday.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isToday(): boolean } } ================================================ FILE: types/plugin/isTomorrow.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isTomorrow(): boolean } } ================================================ FILE: types/plugin/isYesterday.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isYesterday(): boolean } } ================================================ FILE: types/plugin/isoWeek.d.ts ================================================ import { PluginFunc, OpUnitType, ConfigType } from 'dayjs' declare const plugin: PluginFunc export = plugin type ISOUnitType = OpUnitType | 'isoWeek'; declare module 'dayjs' { interface Dayjs { isoWeekYear(): number isoWeek(): number isoWeek(value: number): Dayjs isoWeekday(): number isoWeekday(value: number): Dayjs startOf(unit: ISOUnitType): Dayjs endOf(unit: ISOUnitType): Dayjs isSame(date?: ConfigType, unit?: ISOUnitType): boolean isBefore(date?: ConfigType, unit?: ISOUnitType): boolean isAfter(date?: ConfigType, unit?: ISOUnitType): boolean } } ================================================ FILE: types/plugin/isoWeeksInYear.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { isoWeeksInYear(): number } } ================================================ FILE: types/plugin/localeData.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { type WeekdayNames = [string, string, string, string, string, string, string]; type MonthNames = [string, string, string, string, string, string, string, string, string, string, string, string]; interface InstanceLocaleDataReturn { firstDayOfWeek(): number; weekdays(instance?: Dayjs): WeekdayNames; weekdaysShort(instance?: Dayjs): WeekdayNames; weekdaysMin(instance?: Dayjs): WeekdayNames; months(instance?: Dayjs): MonthNames; monthsShort(instance?: Dayjs): MonthNames; longDateFormat(format: string): string; meridiem(hour?: number, minute?: number, isLower?: boolean): string; ordinal(n: number): string } interface GlobalLocaleDataReturn { firstDayOfWeek(): number; weekdays(): WeekdayNames; weekdaysShort(): WeekdayNames; weekdaysMin(): WeekdayNames; months(): MonthNames; monthsShort(): MonthNames; longDateFormat(format: string): string; meridiem(hour?: number, minute?: number, isLower?: boolean): string; ordinal(n: number): string } interface Dayjs { localeData(): InstanceLocaleDataReturn; } export function weekdays(localOrder?: boolean): WeekdayNames; export function weekdaysShort(localOrder?: boolean): WeekdayNames; export function weekdaysMin(localOrder?: boolean): WeekdayNames; export function monthsShort(): MonthNames; export function months(): MonthNames; export function localeData(): GlobalLocaleDataReturn; } ================================================ FILE: types/plugin/localizedFormat.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/minMax.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { export function max(dayjs: [Dayjs, ...Dayjs[]]): Dayjs export function max(noDates: never[]): null export function max(maybeDates: Dayjs[]): Dayjs | null export function max(...dayjs: [Dayjs, ...Dayjs[]]): Dayjs export function max(...noDates: never[]): null export function max(...maybeDates: Dayjs[]): Dayjs | null export function min(dayjs: [Dayjs, ...Dayjs[]]): Dayjs export function min(noDates: never[]): null export function min(maybeDates: Dayjs[]): Dayjs | null export function min(...dayjs: [Dayjs, ...Dayjs[]]): Dayjs export function min(...noDates: never[]): null export function min(...maybeDates: Dayjs[]): Dayjs | null } ================================================ FILE: types/plugin/negativeYear.d.ts ================================================ import {PluginFunc} from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/objectSupport.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { set(argument: object): Dayjs add(argument: object): Dayjs subtract(argument: object): Dayjs } interface ConfigTypeMap { objectSupport: { years?: number | string; year?: number | string; y?: number | string; months?: number | string; month?: number | string; M?: number | string; days?: number | string; day?: number | string; d?: number | string; dates?: number | string; date?: number | string; D?: number | string; hours?: number | string; hour?: number | string; h?: number | string; minutes?: number | string; minute?: number | string; m?: number | string; seconds?: number | string; second?: number | string; s?: number | string; milliseconds?: number | string; millisecond?: number | string; ms?: number | string; } } } ================================================ FILE: types/plugin/pluralGetSet.d.ts ================================================ import { PluginFunc, UnitType, ConfigType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { years(): number years(value: number): Dayjs months(): number months(value: number): Dayjs dates(): number dates(value: number): Dayjs weeks(): number weeks(value: number): Dayjs days(): number days(value: number): Dayjs hours(): number hours(value: number): Dayjs minutes(): number minutes(value: number): Dayjs seconds(): number seconds(value: number): Dayjs milliseconds(): number milliseconds(value: number): Dayjs } } ================================================ FILE: types/plugin/preParsePostFormat.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin ================================================ FILE: types/plugin/quarterOfYear.d.ts ================================================ import { PluginFunc, ConfigType, QUnitType, OpUnitType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { quarter(): number quarter(quarter: number): Dayjs add(value: number, unit: QUnitType): Dayjs subtract(value: number, unit: QUnitType): Dayjs startOf(unit: QUnitType | OpUnitType): Dayjs endOf(unit: QUnitType | OpUnitType): Dayjs isSame(date?: ConfigType, unit?: QUnitType): boolean isBefore(date?: ConfigType, unit?: QUnitType): boolean isAfter(date?: ConfigType, unit?: QUnitType): boolean } } ================================================ FILE: types/plugin/relativeTime.d.ts ================================================ import { PluginFunc, ConfigType } from 'dayjs' declare interface RelativeTimeThreshold { l: string r?: number d?: string } declare interface RelativeTimeOptions { rounding?: (num: number) => number thresholds?: RelativeTimeThreshold[] } declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { fromNow(withoutSuffix?: boolean): string from(compared: ConfigType, withoutSuffix?: boolean): string toNow(withoutSuffix?: boolean): string to(compared: ConfigType, withoutSuffix?: boolean): string } } ================================================ FILE: types/plugin/timezone.d.ts ================================================ import { PluginFunc, ConfigType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { tz(timezone?: string, keepLocalTime?: boolean): Dayjs offsetName(type?: 'short' | 'long'): string | undefined } interface DayjsTimezone { (date?: ConfigType, timezone?: string): Dayjs (date: ConfigType, format: string, timezone?: string): Dayjs guess(): string setDefault(timezone?: string): void } const tz: DayjsTimezone } ================================================ FILE: types/plugin/toArray.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { toArray(): number[] } } ================================================ FILE: types/plugin/toObject.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin interface DayjsObject { years: number months: number date: number hours: number minutes: number seconds: number milliseconds: number } declare module 'dayjs' { interface Dayjs { toObject(): DayjsObject } } ================================================ FILE: types/plugin/updateLocale.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { export function updateLocale(localeName: string, customConfig: Record): Record } ================================================ FILE: types/plugin/utc.d.ts ================================================ import { PluginFunc, ConfigType } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { utc(keepLocalTime?: boolean): Dayjs local(): Dayjs isUTC(): boolean utcOffset(offset: number | string, keepLocalTime?: boolean): Dayjs } export function utc(config?: ConfigType, format?: string, strict?: boolean): Dayjs } ================================================ FILE: types/plugin/weekOfYear.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { week(): number week(value : number): Dayjs } } ================================================ FILE: types/plugin/weekYear.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { weekYear(): number } } ================================================ FILE: types/plugin/weekday.d.ts ================================================ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc export = plugin declare module 'dayjs' { interface Dayjs { weekday(): number weekday(value: number): Dayjs } }