From 2f1832c1618f8568d2f2c804587223646a62993b Mon Sep 17 00:00:00 2001 From: splashwizard Date: Tue, 26 Jan 2021 14:00:47 +0800 Subject: [PATCH 01/22] fix: fix Bengali [bn] locale monthsShort error --- src/locale/bn.js | 2 +- test/locale/bn.test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/locale/bn.js b/src/locale/bn.js index 5270df67..9d6c9b08 100644 --- a/src/locale/bn.js +++ b/src/locale/bn.js @@ -32,7 +32,7 @@ const locale = { weekdays: 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'), months: 'জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), weekdaysShort: 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'), - monthsShort: 'জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), + monthsShort: 'জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), weekdaysMin: 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'), preparse(string) { return string.replace(/[১২৩৪৫৬৭৮৯০]/g, match => numberMap[match]) diff --git a/test/locale/bn.test.js b/test/locale/bn.test.js index 585b8dfc..3619904b 100644 --- a/test/locale/bn.test.js +++ b/test/locale/bn.test.js @@ -35,6 +35,16 @@ it('Format Month with locale function', () => { } }) +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') From 89580cde75e4eae7ec53605a72ca052065bb3723 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 26 Jan 2021 10:46:43 +0300 Subject: [PATCH 02/22] fix: hotfix for `Duration` types (#1357) closes #1354 --- types/plugin/duration.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/plugin/duration.d.ts b/types/plugin/duration.d.ts index a5b197af..755a219c 100644 --- a/types/plugin/duration.d.ts +++ b/types/plugin/duration.d.ts @@ -14,6 +14,7 @@ declare namespace plugin { ((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 @@ -50,9 +51,9 @@ declare namespace plugin { get(unit: DurationUnitType): number - add: CreateDurationType; + add: AddDurationType - subtract: CreateDurationType + subtract: AddDurationType toJSON(): string From e3e993440d6bb80996294ec8b0436b58ef4ba2c2 Mon Sep 17 00:00:00 2001 From: Becky Conning Date: Wed, 27 Jan 2021 03:28:20 +0000 Subject: [PATCH 03/22] fix: Added Zulu support to customParseFormat (#1359) --- src/plugin/customParseFormat/index.js | 3 ++- test/plugin/customParseFormat.test.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugin/customParseFormat/index.js b/src/plugin/customParseFormat/index.js index a6b41ef1..d9251dbd 100644 --- a/src/plugin/customParseFormat/index.js +++ b/src/plugin/customParseFormat/index.js @@ -8,13 +8,14 @@ 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)?/ // +00:00 -00:00 +0000 or -0000 +00 +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 = {} 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 diff --git a/test/plugin/customParseFormat.test.js b/test/plugin/customParseFormat.test.js index 841b11d8..b6e06a7d 100644 --- a/test/plugin/customParseFormat.test.js +++ b/test/plugin/customParseFormat.test.js @@ -109,6 +109,13 @@ describe('Timezone Offset', () => { 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' @@ -347,3 +354,4 @@ it('parse a string for MMM month format with underscore delimiter', () => { const format2 = 'DD_MMM_YYYY_hhmmss' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) }) + From 137fd63bd461645dab96c6e27f2954298aa6a185 Mon Sep 17 00:00:00 2001 From: hansdaniels <63750717+hansdaniels@users.noreply.github.com> Date: Thu, 28 Jan 2021 06:46:42 +0100 Subject: [PATCH 04/22] fix: timezone plugin DST error (#1352) --- src/plugin/timezone/index.js | 10 +++++----- test/plugin/timezone.test.js | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugin/timezone/index.js b/src/plugin/timezone/index.js index 97f24060..c8f8a467 100644 --- a/src/plugin/timezone/index.js +++ b/src/plugin/timezone/index.js @@ -36,8 +36,6 @@ const getDateTimeFormat = (timezone, options = {}) => { export default (o, c, d) => { let defaultTimezone - const localUtcOffset = d().utcOffset() - const makeFormatParts = (timestamp, timezone, options = {}) => { const date = new Date(timestamp) const dtf = getDateTimeFormat(timezone, options) @@ -96,9 +94,11 @@ export default (o, c, d) => { proto.tz = function (timezone = defaultTimezone, keepLocalTime) { const oldOffset = this.utcOffset() - const target = this.toDate().toLocaleString('en-US', { timeZone: timezone }) - const diff = Math.round((this.toDate() - new Date(target)) / 1000 / 60) - let ins = d(target).$set(MS, this.$ms).utcOffset(localUtcOffset - diff, true) + const date = this.toDate() + const target = date.toLocaleString('en-US', { timeZone: timezone }) + const diff = Math.round((date - new Date(target)) / 1000 / 60) + let ins = d(target).$set(MS, this.$ms) + .utcOffset((-Math.round(date.getTimezoneOffset() / 15) * 15) - diff, true) if (keepLocalTime) { const newOffset = ins.utcOffset() ins = ins.add(oldOffset - newOffset, MIN) diff --git a/test/plugin/timezone.test.js b/test/plugin/timezone.test.js index 4feb7bf3..dfcebf47 100644 --- a/test/plugin/timezone.test.js +++ b/test/plugin/timezone.test.js @@ -101,7 +101,9 @@ describe('Convert', () => { 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') From f0bb918a1722da15bac761f3016778750e52052e Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 4 Feb 2021 11:34:21 +0300 Subject: [PATCH 05/22] chore: revert removed type definitions (#1361) --- types/plugin/duration.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/plugin/duration.d.ts b/types/plugin/duration.d.ts index 755a219c..a7e733fe 100644 --- a/types/plugin/duration.d.ts +++ b/types/plugin/duration.d.ts @@ -6,6 +6,15 @@ 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 }>; @@ -76,4 +85,4 @@ declare module 'dayjs' { */ export const duration: plugin.CreateDurationType; export function isDuration(d: any): d is plugin.Duration -} +} \ No newline at end of file From 55978a1d0603357ce8bd09c6a37ce349220d6441 Mon Sep 17 00:00:00 2001 From: tlegen-k Date: Thu, 4 Feb 2021 03:36:36 -0500 Subject: [PATCH 06/22] fix: update Russian [ru] locale yearStart config (#1372) --- src/locale/ru.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/ru.js b/src/locale/ru.js index 225cd69b..9fa5a6b7 100644 --- a/src/locale/ru.js +++ b/src/locale/ru.js @@ -53,6 +53,7 @@ const locale = { months, monthsShort, weekStart: 1, + yearStart: 4, formats: { LT: 'H:mm', LTS: 'H:mm:ss', From fa2ae342b5d6f52e6798bedabffbb0d886125f26 Mon Sep 17 00:00:00 2001 From: Reko Jokelainen Date: Thu, 11 Feb 2021 16:57:06 +0200 Subject: [PATCH 07/22] fix: Update Finnish [fi] locale to set yearStart (#1378) --- src/locale/fi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/fi.js b/src/locale/fi.js index d03f4cbd..2c46d62d 100644 --- a/src/locale/fi.js +++ b/src/locale/fi.js @@ -47,6 +47,7 @@ const locale = { 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', From fe25af56c473edc7def98624151bd9775ddf6cd2 Mon Sep 17 00:00:00 2001 From: Manuel Zapata <61023484+Zondazx@users.noreply.github.com> Date: Tue, 16 Feb 2021 01:35:19 -0400 Subject: [PATCH 08/22] chore: Fix inconsistencies in README-es-es (#1384) --- docs/es-es/README-es-es.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/es-es/README-es-es.md b/docs/es-es/README-es-es.md index f0f8f94c..a08c3d86 100644 --- a/docs/es-es/README-es-es.md +++ b/docs/es-es/README-es-es.md @@ -1,7 +1,7 @@

Day.js

-

Alternativa ligera, 2kB, a Moment.js, con la misma API moderna

+

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


-> Day.js es una librería JavaScript minimalista que analiza, valida, manipula y muestra fechas y horas para navegadores modernos, manteniendo una API casi totalmente compatible con Moment.js. Si usas Moment.js, ya sabes usar Day.js. +> 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() @@ -42,9 +42,9 @@ dayjs() # Primeros pasos -### Documentation +### Documentación -You can find for more details, API, and other docs on [day.js.org](https://day.js.org/) website. +Puedes encontrar más detalles, la API y otros documentos en [day.js.org](https://day.js.org/) el sitio web. ## Instalación @@ -56,7 +56,7 @@ npm install dayjs --save ## API -Usar las API de Day.js para analizar, validar, manipular y mostrar fechas y horas es muy sencillo. +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 @@ -125,4 +125,4 @@ Por favor, danos una 💖 estrella 💖 para apoyarnos. Gracias. ## Licencia -Day.js está licenciada bajo la [Licencia MIT](./LICENSE). +Day.js está licenciado bajo la [Licencia MIT](./LICENSE). From ea89782a742f663f4e00c6e2b45d0d015fcd9f14 Mon Sep 17 00:00:00 2001 From: frehoy Date: Tue, 16 Feb 2021 06:39:01 +0100 Subject: [PATCH 09/22] fix: update Swedish [sv] locale to set correct yearStart (#1385) --- src/locale/sv.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/sv.js b/src/locale/sv.js index 493e3152..cc8e8e79 100644 --- a/src/locale/sv.js +++ b/src/locale/sv.js @@ -9,6 +9,7 @@ const locale = { 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' From 809d9d9b00b6ff00f70db7c0c60af1d6fe951c69 Mon Sep 17 00:00:00 2001 From: Simon B Date: Tue, 16 Feb 2021 06:40:17 +0100 Subject: [PATCH 10/22] fix: update Slovenian [sl] locale to set correct ordinal (#1386) --- src/locale/sl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/sl.js b/src/locale/sl.js index e66101a0..f09e3bfc 100644 --- a/src/locale/sl.js +++ b/src/locale/sl.js @@ -9,7 +9,7 @@ const locale = { 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, + ordinal: n => `${n}.`, formats: { LT: 'H:mm', LTS: 'H:mm:ss', From e2e9824a654ba78f1ecb7f33364c814baef8221f Mon Sep 17 00:00:00 2001 From: mateuszpigula <34506960+mateuszpigula@users.noreply.github.com> Date: Wed, 3 Mar 2021 06:57:47 +0100 Subject: [PATCH 11/22] fix: Update duration plugin change string to number (#1394) --- src/plugin/duration/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugin/duration/index.js b/src/plugin/duration/index.js index 45083403..854c7463 100644 --- a/src/plugin/duration/index.js +++ b/src/plugin/duration/index.js @@ -79,7 +79,9 @@ class Duration { if (typeof input === 'string') { const d = input.match(durationRegex) if (d) { - [,, + const properties = d.slice(2) + const numberD = properties.map(value => Number(value)); + [ this.$d.years, this.$d.months, this.$d.weeks, @@ -87,7 +89,7 @@ class Duration { this.$d.hours, this.$d.minutes, this.$d.seconds - ] = d + ] = numberD this.calMilliseconds() return this } From 81d0c60b8adcd02c9f456cfad7aa81a0c809f4dd Mon Sep 17 00:00:00 2001 From: Sang <11912225+hantatsang@users.noreply.github.com> Date: Sat, 6 Mar 2021 23:21:04 +1100 Subject: [PATCH 12/22] fix(): add meridiem in ar locales (#1375) --- src/locale/ar-dz.js | 1 + src/locale/ar-kw.js | 1 + src/locale/ar-ly.js | 1 + src/locale/ar-ma.js | 1 + src/locale/ar-sa.js | 1 + src/locale/ar-tn.js | 1 + 6 files changed, 6 insertions(+) diff --git a/src/locale/ar-dz.js b/src/locale/ar-dz.js index 8529a33d..fdc5e0b8 100644 --- a/src/locale/ar-dz.js +++ b/src/locale/ar-dz.js @@ -17,6 +17,7 @@ const locale = { LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), relativeTime: { future: 'في %s', past: 'منذ %s', diff --git a/src/locale/ar-kw.js b/src/locale/ar-kw.js index 72a2b011..23ad4be6 100644 --- a/src/locale/ar-kw.js +++ b/src/locale/ar-kw.js @@ -17,6 +17,7 @@ const locale = { LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), relativeTime: { future: 'في %s', past: 'منذ %s', diff --git a/src/locale/ar-ly.js b/src/locale/ar-ly.js index b0d0982e..6db39705 100644 --- a/src/locale/ar-ly.js +++ b/src/locale/ar-ly.js @@ -10,6 +10,7 @@ const locale = { monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), ordinal: n => n, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', diff --git a/src/locale/ar-ma.js b/src/locale/ar-ma.js index 39b80ef9..802b7168 100644 --- a/src/locale/ar-ma.js +++ b/src/locale/ar-ma.js @@ -18,6 +18,7 @@ const locale = { LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), relativeTime: { future: 'في %s', past: 'منذ %s', diff --git a/src/locale/ar-sa.js b/src/locale/ar-sa.js index fd28501f..9f908ade 100644 --- a/src/locale/ar-sa.js +++ b/src/locale/ar-sa.js @@ -17,6 +17,7 @@ const locale = { LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), relativeTime: { future: 'في %s', past: 'منذ %s', diff --git a/src/locale/ar-tn.js b/src/locale/ar-tn.js index 99fcff2d..54c4e3e2 100644 --- a/src/locale/ar-tn.js +++ b/src/locale/ar-tn.js @@ -18,6 +18,7 @@ const locale = { LLL: 'D MMMM YYYY HH:mm', LLLL: 'dddd D MMMM YYYY HH:mm' }, + meridiem: hour => (hour > 12 ? 'ص' : 'م'), relativeTime: { future: 'في %s', past: 'منذ %s', From c869a3be56224a0087d3e0855e716718f6e199bd Mon Sep 17 00:00:00 2001 From: Jesus The Hun Date: Mon, 8 Mar 2021 08:02:32 +0100 Subject: [PATCH 13/22] fix: update Duration plugin to support no-argument (#1400) --- src/plugin/duration/index.js | 4 ++++ test/plugin/duration.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/plugin/duration/index.js b/src/plugin/duration/index.js index 854c7463..4e894647 100644 --- a/src/plugin/duration/index.js +++ b/src/plugin/duration/index.js @@ -61,6 +61,10 @@ 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) } diff --git a/test/plugin/duration.test.js b/test/plugin/duration.test.js index b8d6378f..cca1a828 100644 --- a/test/plugin/duration.test.js +++ b/test/plugin/duration.test.js @@ -17,6 +17,10 @@ afterEach(() => { }) 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') From 62093a24eb241a73f758e171a616e5de0141bf3c Mon Sep 17 00:00:00 2001 From: CJ Skillingstad Date: Mon, 8 Mar 2021 20:27:56 -0800 Subject: [PATCH 14/22] fix: update Russian [ru] locale meridiem and unit tests (#1403) --- src/locale/ru.js | 12 +++++++++++- test/locale/ru.test.js | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/locale/ru.js b/src/locale/ru.js index 9fa5a6b7..801c8592 100644 --- a/src/locale/ru.js +++ b/src/locale/ru.js @@ -77,7 +77,17 @@ const locale = { y: 'год', yy: relativeTimeWithPlural }, - ordinal: n => n + 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) diff --git a/test/locale/ru.test.js b/test/locale/ru.test.js index 9044eb59..7f285f63 100644 --- a/test/locale/ru.test.js +++ b/test/locale/ru.test.js @@ -47,3 +47,10 @@ it('RelativeTime: Time from X', () => { .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('вечера') +}) From 0ffec61fc5165ab37184ef4f8462ef4262ba08f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ognjen=20Jevremovi=C4=87?= Date: Wed, 10 Mar 2021 07:02:09 +0100 Subject: [PATCH 15/22] fix: update UTC plugin to support string argument like +HH:mm (#1395) --- src/plugin/utc/index.js | 27 +++++++++++++++++ test/plugin/utc.test.js | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index b5b5f4e6..8f840590 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -1,5 +1,26 @@ import { MILLISECONDS_A_MINUTE, MIN } from '../../constant' +export const REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g +export 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) { @@ -59,6 +80,12 @@ export default (option, Dayjs, dayjs) => { } 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 let ins = this if (keepLocalTime) { diff --git a/test/plugin/utc.test.js b/test/plugin/utc.test.js index 888412a8..2dd5c0c3 100644 --- a/test/plugin/utc.test.js +++ b/test/plugin/utc.test.js @@ -226,6 +226,71 @@ describe('UTC Offset', () => { 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()) + }) }) describe('Diff', () => { From b0f77a1e6e837c181914ba47cc1e806e7c881ab1 Mon Sep 17 00:00:00 2001 From: Jason Kwok <4410086+JasonHK@users.noreply.github.com> Date: Wed, 10 Mar 2021 14:29:36 +0800 Subject: [PATCH 16/22] fix: fix missing types for ArraySupport plugin (#1401) --- types/index.d.ts | 6 +++++- types/plugin/arraySupport.d.ts | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 22efc9eb..d83c9dde 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -9,7 +9,11 @@ declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, stri declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean): dayjs.Dayjs declare namespace dayjs { - export type ConfigType = string | number | Date | Dayjs + interface ConfigTypeMap { + default: string | number | Date | Dayjs + } + + export type ConfigType = ConfigTypeMap[keyof ConfigTypeMap] export type OptionType = { locale?: string, format?: string, utc?: boolean } | string | string[] diff --git a/types/plugin/arraySupport.d.ts b/types/plugin/arraySupport.d.ts index 30ec75e5..e4e44b2e 100755 --- a/types/plugin/arraySupport.d.ts +++ b/types/plugin/arraySupport.d.ts @@ -1,4 +1,10 @@ import { PluginFunc } from 'dayjs' +declare module 'dayjs' { + interface ConfigTypeMap { + arraySupport: [number?, number?, number?, number?, number?, number?, number?] + } +} + declare const plugin: PluginFunc export = plugin From 2eeabb115eee830bbd5c64d31289745bfd292f71 Mon Sep 17 00:00:00 2001 From: Jamil Chioino <39961109+jamilchioino@users.noreply.github.com> Date: Sun, 14 Mar 2021 22:50:33 -0500 Subject: [PATCH 17/22] fix: update Spanish [es] locale to change month names to lowercase (#1414) --- src/locale/es-do.js | 2 +- src/locale/es-pr.js | 2 +- src/locale/es-us.js | 2 +- src/locale/es.js | 2 +- test/locale.test.js | 26 +++++++++++++------------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/locale/es-do.js b/src/locale/es-do.js index 45002d07..95abee59 100644 --- a/src/locale/es-do.js +++ b/src/locale/es-do.js @@ -6,7 +6,7 @@ const locale = { 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('_'), + 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: { diff --git a/src/locale/es-pr.js b/src/locale/es-pr.js index f8c20c3a..7b923a98 100644 --- a/src/locale/es-pr.js +++ b/src/locale/es-pr.js @@ -7,7 +7,7 @@ const locale = { 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('_'), + months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), weekStart: 1, formats: { LT: 'h:mm A', diff --git a/src/locale/es-us.js b/src/locale/es-us.js index cc81c484..9aeecdb4 100644 --- a/src/locale/es-us.js +++ b/src/locale/es-us.js @@ -6,7 +6,7 @@ const locale = { 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('_'), + 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', diff --git a/src/locale/es.js b/src/locale/es.js index 951e7f53..c75588fd 100644 --- a/src/locale/es.js +++ b/src/locale/es.js @@ -7,7 +7,7 @@ const locale = { 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('_'), + months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), weekStart: 1, formats: { LT: 'H:mm', diff --git a/test/locale.test.js b/test/locale.test.js index 7faab1d0..0e6fd06e 100644 --- a/test/locale.test.js +++ b/test/locale.test.js @@ -17,7 +17,7 @@ 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') + .toBe('sábado 28, abril') }) it('set locale for one instance only', () => { @@ -27,7 +27,7 @@ it('set locale for one instance only', () => { expect(dayjs('2018-4-28') .locale(es).format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') expect(dayjs('2018-4-28') .format(format)) @@ -40,7 +40,7 @@ it('set global locale', () => { .toBe('Saturday 28, April') dayjs.locale(es) expect(dayjs('2018-4-28').format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') dayjs.locale('en') expect(dayjs('2018-4-28').format(format)) .toBe('Saturday 28, April') @@ -63,10 +63,10 @@ it('immutable instance locale', () => { expect(origin.format(format)) .toBe('Saturday 28, April') expect(origin.locale('es').format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') const changed = origin.locale('es') expect(changed.format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') expect(origin.format(format)) .toBe('Saturday 28, April') }) @@ -86,30 +86,30 @@ describe('Instance locale inheritance', () => { it('Clone', () => { expect(esDayjs.clone().format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') expect(dayjs(esDayjs).format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') }) it('StartOf EndOf', () => { expect(esDayjs.startOf('year').format(format)) - .toBe('lunes 1, Enero') + .toBe('lunes 1, enero') expect(esDayjs.endOf('day').format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') }) it('Set', () => { expect(esDayjs.set('year', 2017).format(format)) - .toBe('viernes 28, Abril') + .toBe('viernes 28, abril') }) it('Add', () => { expect(esDayjs.add(1, 'year').format(format)) - .toBe('domingo 28, Abril') + .toBe('domingo 28, abril') expect(esDayjs.add(1, 'month').format(format)) - .toBe('lunes 28, Mayo') + .toBe('lunes 28, mayo') expect(esDayjs.add(1, 'minute').format(format)) - .toBe('sábado 28, Abril') + .toBe('sábado 28, abril') }) it('dayjs.locale() returns locale name', () => { From a1b8e17105b98332c62f2a7c7029e5bc5f492e75 Mon Sep 17 00:00:00 2001 From: splashwizard Date: Tue, 20 Apr 2021 20:56:43 +0800 Subject: [PATCH 18/22] fix: fix Ukrainian [uk] locale (#1463) --- src/locale/uk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/uk.js b/src/locale/uk.js index e973dedc..fdc9aa65 100644 --- a/src/locale/uk.js +++ b/src/locale/uk.js @@ -43,7 +43,7 @@ const locale = { weekdaysShort: 'ндл_пнд_втр_срд_чтв_птн_сбт'.split('_'), weekdaysMin: 'нд_пн_вт_ср_чт_пт_сб'.split('_'), months, - monthsShort: 'січ_лют_бер_квiт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'), + monthsShort: 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'), weekStart: 1, relativeTime: { future: 'за %s', From 47355828227e71735275e17a70e5564f04df734c Mon Sep 17 00:00:00 2001 From: splashwizard Date: Sun, 9 May 2021 00:28:01 +0800 Subject: [PATCH 19/22] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d5939702..9e665b78 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/R src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png" alt="Day.js">

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

-

-多会

Date: Wed, 26 May 2021 07:05:16 +0100 Subject: [PATCH 20/22] Fix broken UTC plugin due to rollup (#1453) --- build/index.js | 22 +++++++++++++--------- build/rollup.config.js | 7 ++++--- package.json | 9 ++++----- src/constant.js | 4 ++++ src/plugin/utc/index.js | 5 +---- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/build/index.js b/build/index.js index 4651dd61..4dd7708c 100644 --- a/build/index.js +++ b/build/index.js @@ -35,23 +35,27 @@ async function listLocaleJson(localeArr) { (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) - locales.forEach((l) => { - build(configFactory({ + 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')) - plugins.forEach((l) => { - build(configFactory({ - input: `./src/plugin/${l}/index`, - fileName: `./plugin/${l}.js`, - name: `dayjs_plugin_${formatName(l)}` + 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', diff --git a/build/rollup.config.js b/build/rollup.config.js index 4d31b990..b3a66108 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,5 +1,5 @@ const babel = require('rollup-plugin-babel') -const uglify = require('rollup-plugin-uglify') +const { terser } = require('rollup-plugin-terser') module.exports = (config) => { const { input, fileName, name } = config @@ -13,7 +13,7 @@ module.exports = (config) => { babel({ exclude: 'node_modules/**' }), - uglify() + terser() ] }, output: { @@ -22,7 +22,8 @@ module.exports = (config) => { name: name || 'dayjs', globals: { dayjs: 'dayjs' - } + }, + compact: true } } } diff --git a/package.json b/package.json index 29f0f171..de6c65f8 100644 --- a/package.json +++ b/package.json @@ -90,11 +90,10 @@ "ncp": "^2.0.0", "pre-commit": "^1.2.2", "prettier": "^1.16.1", - "rollup": "^0.57.1", - "rollup-plugin-babel": "^4.0.0-beta.4", - "rollup-plugin-uglify": "^3.0.0", + "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" - }, - "dependencies": {} + } } diff --git a/src/constant.js b/src/constant.js index 6be602e2..f6af3efe 100644 --- a/src/constant.js +++ b/src/constant.js @@ -28,3 +28,7 @@ export const INVALID_DATE_STRING = 'Invalid Date' // regex export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/ export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|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 + +// used by plugins/utc +export const REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g +export const REGEX_OFFSET_HOURS_MINUTES_FORMAT = /([+-]|\d\d)/g diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index 8f840590..7e842b3b 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -1,7 +1,4 @@ -import { MILLISECONDS_A_MINUTE, MIN } from '../../constant' - -export const REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g -export const REGEX_OFFSET_HOURS_MINUTES_FORMAT = /([+-]|\d\d)/g +import { MILLISECONDS_A_MINUTE, MIN, REGEX_VALID_OFFSET_FORMAT, REGEX_OFFSET_HOURS_MINUTES_FORMAT } from '../../constant' function offsetFromString(value = '') { const offset = value.match(REGEX_VALID_OFFSET_FORMAT) From 460cb36273b9fbaf325b3f048a953e144143bb7d Mon Sep 17 00:00:00 2001 From: splashwizard Date: Wed, 26 May 2021 14:37:03 +0800 Subject: [PATCH 21/22] test: add utc plugin test --- src/constant.js | 4 ---- src/plugin/utc/index.js | 5 ++++- test/plugin/utc.test.js | 10 ++++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/constant.js b/src/constant.js index f6af3efe..6be602e2 100644 --- a/src/constant.js +++ b/src/constant.js @@ -28,7 +28,3 @@ export const INVALID_DATE_STRING = 'Invalid Date' // regex export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/ export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|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 - -// used by plugins/utc -export const REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g -export const REGEX_OFFSET_HOURS_MINUTES_FORMAT = /([+-]|\d\d)/g diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index 7e842b3b..10ff1ec9 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -1,4 +1,7 @@ -import { MILLISECONDS_A_MINUTE, MIN, REGEX_VALID_OFFSET_FORMAT, REGEX_OFFSET_HOURS_MINUTES_FORMAT } from '../../constant' +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) diff --git a/test/plugin/utc.test.js b/test/plugin/utc.test.js index 2dd5c0c3..b8fc9259 100644 --- a/test/plugin/utc.test.js +++ b/test/plugin/utc.test.js @@ -291,6 +291,16 @@ describe('UTC Offset', () => { 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', () => { From 507141713fe1508f3a10e7b053649cbefa97cacc Mon Sep 17 00:00:00 2001 From: splashwizard Date: Wed, 26 May 2021 14:48:53 +0800 Subject: [PATCH 22/22] chore: add ignore --- src/locale/br.js | 1 + src/plugin/devHelper/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/locale/br.js b/src/locale/br.js index 17e4ee50..65e76e18 100644 --- a/src/locale/br.js +++ b/src/locale/br.js @@ -30,6 +30,7 @@ function relativeTimeWithMutation(number, withoutSuffix, key) { return `${number} ${mutation(format[key], number)}` } function specialMutationForYears(number) { + /* istanbul ignore next line */ switch (lastNumber(number)) { case 1: case 3: diff --git a/src/plugin/devHelper/index.js b/src/plugin/devHelper/index.js index b4fb3c6f..bdb83caf 100644 --- a/src/plugin/devHelper/index.js +++ b/src/plugin/devHelper/index.js @@ -1,5 +1,6 @@ /* 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