From 22a249c349a61169b463558cc917168142723384 Mon Sep 17 00:00:00 2001 From: iamkun Date: Tue, 12 Mar 2019 19:01:01 +0800 Subject: [PATCH 1/8] fix: Correct typescript definition `add` fix #531 --- types/index.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index eee848e61..a04c66eaa 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -7,10 +7,9 @@ declare namespace dayjs { export type OptionType = { locale?: string, format?: string, utc?: boolean } | string type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' - export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'quarter' | 'year' | 'date' | UnitTypeShort; + export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | UnitTypeShort; - type OpUnitTypeShort = 'w' - export type OpUnitType = UnitType | "week" | OpUnitTypeShort; + export type OpUnitType = UnitType | "week" | 'w'; class Dayjs { constructor (config?: ConfigType) @@ -63,7 +62,7 @@ declare namespace dayjs { format(template?: string): string - diff(date: ConfigType, unit: OpUnitType, float?: boolean): number + diff(date: ConfigType, unit: OpUnitType | 'quarter', float?: boolean): number valueOf(): number From eeb20fa4a569d7e028a6dcbb1919b7e42ffa5363 Mon Sep 17 00:00:00 2001 From: Haqverdi Behbudov Date: Sun, 17 Mar 2019 09:33:25 +0400 Subject: [PATCH 2/8] fix: Add locale support for Azerbaijani language (az) (#535) --- src/locale/az.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/locale/az.js diff --git a/src/locale/az.js b/src/locale/az.js new file mode 100644 index 000000000..cddb2b85b --- /dev/null +++ b/src/locale/az.js @@ -0,0 +1,39 @@ +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 From 85785462f873a936ae31df5772e8f21940338ef9 Mon Sep 17 00:00:00 2001 From: Waseem Ahmad <42496021+waseemahmad31@users.noreply.github.com> Date: Mon, 18 Mar 2019 08:11:21 +0530 Subject: [PATCH 3/8] fix: Fix CustomParseFormat plugin formatting bug (#536) fix: #533 --- src/plugin/customParseFormat/index.js | 2 +- test/plugin/customParseFormat.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugin/customParseFormat/index.js b/src/plugin/customParseFormat/index.js index 0851d4edd..6386650c7 100644 --- a/src/plugin/customParseFormat/index.js +++ b/src/plugin/customParseFormat/index.js @@ -9,7 +9,7 @@ const matchUpperCaseAMPM = /[AP]M/ const matchLowerCaseAMPM = /[ap]m/ const matchSigned = /[+-]?\d+/ // -inf - inf const matchOffset = /[+-]\d\d:?\d\d/ // +00:00 -00:00 +0000 or -0000 -const matchWord = /\d*[^\s\d]+/ // Word +const matchWord = /\d*[^\s\d-:/.()]+/ // Word let locale diff --git a/test/plugin/customParseFormat.test.js b/test/plugin/customParseFormat.test.js index 46286bc66..49462f439 100644 --- a/test/plugin/customParseFormat.test.js +++ b/test/plugin/customParseFormat.test.js @@ -26,6 +26,12 @@ it('parse padded string', () => { 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()) +}) + it('parse string January (getMonth() = 0)', () => { const input = '01/01/2019' const format = 'DD/MM/YYYY' From 1ac9e1e759c3fcb8aa567902c516409b2b86347e Mon Sep 17 00:00:00 2001 From: ptdev Date: Mon, 18 Mar 2019 15:42:36 +0000 Subject: [PATCH 4/8] fix: Update pt locale (#538) Added some missing properties and localized formats --- src/locale/pt.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/locale/pt.js b/src/locale/pt.js index 298cf6328..328397462 100644 --- a/src/locale/pt.js +++ b/src/locale/pt.js @@ -3,9 +3,19 @@ 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('_'), 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, + 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', From dde39e9660a7e9a511ab3ed58f151559b96e930b Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 21 Mar 2019 12:28:39 +0800 Subject: [PATCH 5/8] fix: Add .add('quarter') .startOf('quarter') through plugin quarterOfYear fix #537, fix #531 --- src/plugin/quarterOfYear/index.js | 31 ++++++++++++++++++++++++++++++- src/utils.js | 3 ++- test/plugin/quarterOfYear.test.js | 28 +++++++++++++++++++++++++++- test/utils.test.js | 3 +++ types/index.d.ts | 3 ++- types/plugin/quarterOfYear.d.ts | 12 +++++++++++- 6 files changed, 75 insertions(+), 5 deletions(-) diff --git a/src/plugin/quarterOfYear/index.js b/src/plugin/quarterOfYear/index.js index 755d608b9..0ec48906b 100644 --- a/src/plugin/quarterOfYear/index.js +++ b/src/plugin/quarterOfYear/index.js @@ -1,6 +1,35 @@ +import { Q, M, D } from '../../constant' + export default (o, c) => { const proto = c.prototype - proto.quarter = function () { + proto.quarter = function (quarter) { + if (!this.$utils().u(quarter)) { + return this.add((quarter - 1) * 3, M) + } 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) + } } diff --git a/src/utils.js b/src/utils.js index cd98b07cd..01921d46e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -35,7 +35,8 @@ const prettyUnit = (u) => { h: C.H, m: C.MIN, s: C.S, - ms: C.MS + ms: C.MS, + Q: C.Q } return special[u] || String(u || '').toLowerCase().replace(/s$/, '') } diff --git a/test/plugin/quarterOfYear.test.js b/test/plugin/quarterOfYear.test.js index 857dd4d9a..a1fe0e360 100644 --- a/test/plugin/quarterOfYear.test.js +++ b/test/plugin/quarterOfYear.test.js @@ -1,4 +1,5 @@ import MockDate from 'mockdate' +import moment from 'moment' import dayjs from '../../src' import quarterOfYear from '../../src/plugin/quarterOfYear' @@ -12,7 +13,7 @@ afterEach(() => { MockDate.reset() }) -it('QuarterOfYear', () => { +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) @@ -22,3 +23,28 @@ it('QuarterOfYear', () => { 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).valueOf()).toBe(1364745600000) + 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).valueOf()).toBe(1367701567000) + expect(dayjs(d2).quarter(2).format()) + .toBe(moment(d2).quarter(2).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()) +}) diff --git a/test/utils.test.js b/test/utils.test.js index 5c07f7796..f49dcf50e 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -8,6 +8,9 @@ it('PrettyUnit', () => { expect(prettyUnit('Days')).toBe('day') expect(prettyUnit('days')).toBe('day') expect(prettyUnit('day')).toBe('day') + expect(prettyUnit('Q')).toBe('quarter') + expect(prettyUnit('quarter')).toBe('quarter') + expect(prettyUnit('quarters')).toBe('quarter') expect(prettyUnit()).toBe('') }) diff --git a/types/index.d.ts b/types/index.d.ts index a04c66eaa..f32c4c003 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -10,6 +10,7 @@ declare namespace dayjs { export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | UnitTypeShort; export type OpUnitType = UnitType | "week" | 'w'; + export type QUnitType = UnitType | "quarter" | 'Q'; class Dayjs { constructor (config?: ConfigType) @@ -62,7 +63,7 @@ declare namespace dayjs { format(template?: string): string - diff(date: ConfigType, unit: OpUnitType | 'quarter', float?: boolean): number + diff(date: ConfigType, unit: QUnitType, float?: boolean): number valueOf(): number diff --git a/types/plugin/quarterOfYear.d.ts b/types/plugin/quarterOfYear.d.ts index e8aad14b8..f77f032c0 100644 --- a/types/plugin/quarterOfYear.d.ts +++ b/types/plugin/quarterOfYear.d.ts @@ -1,4 +1,4 @@ -import { PluginFunc } from 'dayjs' +import { PluginFunc, QUnitType } from 'dayjs' declare const plugin: PluginFunc export = plugin @@ -6,5 +6,15 @@ 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): Dayjs + + endOf(unit: QUnitType): Dayjs } } From 723f61a85491e446e80d9c5b17ae5e4e2d43da76 Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 21 Mar 2019 12:36:03 +0800 Subject: [PATCH 6/8] docs: Update quarterOfYear docs --- docs/en/Plugin.md | 3 ++- docs/es-es/Plugin.md | 3 ++- docs/ja/Plugin.md | 3 ++- docs/ko/Plugin.md | 3 ++- docs/pt-br/Plugin.md | 3 ++- docs/zh-cn/Plugin.md | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index bddd23bdf..aa862a392 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -292,6 +292,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat diff --git a/docs/es-es/Plugin.md b/docs/es-es/Plugin.md index 9d30c29f1..fd677ed3d 100644 --- a/docs/es-es/Plugin.md +++ b/docs/es-es/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear añade a la API `.quarter()` para devolver a que cuarto del año pertenece una fecha +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -292,6 +292,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index db28bcc58..8f8d27654 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -293,7 +293,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -301,6 +301,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index af6f11016..93f838d36 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -285,7 +285,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -293,6 +293,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index 2fa6af1b5..942326e7b 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -292,6 +292,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index c5c0ae2b3..1994e628d 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -283,7 +283,7 @@ dayjs('2018-06-27').week(5) // 设置周 ### QuarterOfYear -- QuarterOfYear 增加了 `.quarter()` API `number` 来表示 `Dayjs` 的日期是第几个季度. +- QuarterOfYear 增加了 `.quarter()` API 返回一个 `number` 来表示 `Dayjs` 的日期是第几个季度,并扩展了 `.add`, `.subtract`, `.startOf`, `.endOf` API 来支持 `quarter` 季度单位。 ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -291,6 +291,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear' dayjs.extend(quarterOfYear) dayjs('2010-04-01').quarter() // 2 +dayjs('2010-04-01').quarter(2) ``` ### CustomParseFormat From 0f692c557a4d98e3014b4949d52de2236fa4d4d0 Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 21 Mar 2019 12:37:55 +0800 Subject: [PATCH 7/8] docs: fix doc error --- docs/en/Plugin.md | 2 +- docs/es-es/Plugin.md | 2 +- docs/ja/Plugin.md | 2 +- docs/ko/Plugin.md | 2 +- docs/pt-br/Plugin.md | 2 +- docs/zh-cn/Plugin.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index aa862a392..ba60aaa93 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' diff --git a/docs/es-es/Plugin.md b/docs/es-es/Plugin.md index fd677ed3d..c78bc4e6d 100644 --- a/docs/es-es/Plugin.md +++ b/docs/es-es/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index 8f8d27654..faabaebbf 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -293,7 +293,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index 93f838d36..c91449ed3 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -285,7 +285,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index 942326e7b..7a5c7611f 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add`, `.subtract`, `.startOf`, `.endOf` API to support unit `quarter`. +- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 1994e628d..486756cfa 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -283,7 +283,7 @@ dayjs('2018-06-27').week(5) // 设置周 ### QuarterOfYear -- QuarterOfYear 增加了 `.quarter()` API 返回一个 `number` 来表示 `Dayjs` 的日期是第几个季度,并扩展了 `.add`, `.subtract`, `.startOf`, `.endOf` API 来支持 `quarter` 季度单位。 +- QuarterOfYear 增加了 `.quarter()` API 返回一个 `number` 来表示 `Dayjs` 的日期是第几个季度,并扩展了 `.add` `.subtract` `.startOf` `.endOf` API 来支持 `quarter` 季度单位。 ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' From 0edabcd89e6a3149c77acaf5a0101a913867133d Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 21 Mar 2019 12:46:12 +0800 Subject: [PATCH 8/8] test: remove local test --- test/plugin/quarterOfYear.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/plugin/quarterOfYear.test.js b/test/plugin/quarterOfYear.test.js index a1fe0e360..9b7152531 100644 --- a/test/plugin/quarterOfYear.test.js +++ b/test/plugin/quarterOfYear.test.js @@ -26,11 +26,9 @@ it('get QuarterOfYear', () => { it('set QuarterOfYear', () => { const d1 = '2013-01-01T00:00:00.000' - expect(dayjs(d1).quarter(2).valueOf()).toBe(1364745600000) 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).valueOf()).toBe(1367701567000) expect(dayjs(d2).quarter(2).format()) .toBe(moment(d2).quarter(2).format()) })