diff --git a/docs/en/I18n.md b/docs/en/I18n.md index 401063aaf..f1100da0a 100644 --- a/docs/en/I18n.md +++ b/docs/en/I18n.md @@ -92,6 +92,7 @@ const localeObject = { weekdaysShort: 'Sun_M'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided weekdaysMin: 'Su_Mo'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided weekStart: 1, // OPTIONAL, set the start of a week. If the value is 1, Monday will be the start of week instead of Sunday。 + yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. months: 'Enero_Febrero ... '.split('_'), // months Array monthsShort: 'Jan_F'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided ordinal: n => `${n}º`, // ordinal Function (number) => return number + output diff --git a/docs/es-es/I18n.md b/docs/es-es/I18n.md index 989269708..839fb2666 100644 --- a/docs/es-es/I18n.md +++ b/docs/es-es/I18n.md @@ -95,6 +95,8 @@ const localeObject = { weekdays: 'Domingo_Lunes ...'.split('_'), // weekdays Array weekdaysShort: 'Sun_M'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided weekdaysMin: 'Su_Mo'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided + weekStart: 1, // OPTIONAL, set the start of a week. If the value is 1, Monday will be the start of week instead of Sunday。 + yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. months: 'Enero_Febrero ... '.split('_'), // months Array monthsShort: 'Jan_F'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided ordinal: n => `${n}º`, // ordinal Function (number) => return number + output diff --git a/docs/ja/I18n.md b/docs/ja/I18n.md index a0dab94f0..1fb090b76 100644 --- a/docs/ja/I18n.md +++ b/docs/ja/I18n.md @@ -92,6 +92,7 @@ const localeObject = { weekdaysShort: 'Sun_M'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided weekdaysMin: 'Su_Mo'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided weekStart: 1, // OPTIONAL, 最初の曜日を指定する。0は日曜日です。1は月曜日です。 + yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. months: 'Enero_Febrero ... '.split('_'), // 月の配列 monthsShort: 'Jan_F'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided ordinal: n => `${n}º`, // 序数 Function (number) => return number + output diff --git a/docs/ko/I18n.md b/docs/ko/I18n.md index 5df968cdc..e7d73320f 100644 --- a/docs/ko/I18n.md +++ b/docs/ko/I18n.md @@ -92,6 +92,7 @@ const localeObject = { weekdaysShort: 'Sun_M'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided weekdaysMin: 'Su_Mo'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided weekStart: 1, // OPTIONAL, set the start of a week. If the value is 1, Monday will be the start of week instead of Sunday。 + yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. months: 'Enero_Febrero ... '.split('_'), // months Array monthsShort: 'Jan_F'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided ordinal: n => `${n}º`, // ordinal Function (number) => return number + output diff --git a/docs/pt-br/I18n.md b/docs/pt-br/I18n.md index 4a383ecf2..18fef9b55 100644 --- a/docs/pt-br/I18n.md +++ b/docs/pt-br/I18n.md @@ -92,6 +92,7 @@ const objetoLocale = { weekdaysShort: 'Sun_M'.split('_'), // OPCIONAL, dias da semana com nome curto: Array, utiliza as três primeiras letras se nenhuma for especificada weekdaysMin: 'Su_Mo'.split('_'), // OPCIONAL, dias da semana com nome mínimo: Array, utiliza as duas primeiras letras se nenhuma for especificada weekStart: 1, // OPCIONAL, define o início da semana. Se o valor for 1, Segunda-feira será o início da semana ao invés de Domingo。 + yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. months: 'Enero_Febrero ... '.split('_'), // meses: Array monthsShort: 'Jan_F'.split('_'), // OPCIONAL, meses com nome curto: Array, utiliza as três primeiras letras se nenhuma for especificada ordinal: n => `${n}º`, // ordinal: Function (number) => retorna number + saída diff --git a/docs/zh-cn/I18n.md b/docs/zh-cn/I18n.md index 55b4aa108..29e1875b6 100644 --- a/docs/zh-cn/I18n.md +++ b/docs/zh-cn/I18n.md @@ -92,6 +92,7 @@ const localeObject = { weekdaysShort: 'Sun_M'.split('_'), // 可选, 短的星期 Array, 如果没提供则使用前三个字符 weekdaysMin: 'Su_Mo'.split('_'), // 可选, 最短的星期 Array, 如果没提供则使用前两个字符 weekStart: 1, // 可选,指定一周的第一天。默认为0,即周日。如果为1,则周一为一周得第一天。 + yearStart: 4, // 可选,包含1月4日的周为一年的第一周 months: 'Enero_Febrero ... '.split('_'), // 月份 Array monthsShort: 'Jan_F'.split('_'), // 可选, 短的月份 Array, 如果没提供则使用前三个字符 ordinal: n => `${n}º`, // 序号生成工厂函数 Function (number) => return number + output diff --git a/src/locale/af.js b/src/locale/af.js index ff7bd77d0..462e72958 100644 --- a/src/locale/af.js +++ b/src/locale/af.js @@ -1,3 +1,4 @@ +// Afrikaans [af] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-dz.js b/src/locale/ar-dz.js index a97eb11c9..8529a33d2 100644 --- a/src/locale/ar-dz.js +++ b/src/locale/ar-dz.js @@ -1,3 +1,4 @@ +// Arabic (Algeria) [ar-dz] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-kw.js b/src/locale/ar-kw.js index e431eda1a..2ed0fbc8b 100644 --- a/src/locale/ar-kw.js +++ b/src/locale/ar-kw.js @@ -1,3 +1,4 @@ +// Arabic (Kuwait) [ar-kw] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-ly.js b/src/locale/ar-ly.js index cfdf1327e..b0d0982eb 100644 --- a/src/locale/ar-ly.js +++ b/src/locale/ar-ly.js @@ -1,3 +1,4 @@ +// Arabic (Lybia) [ar-ly] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-ma.js b/src/locale/ar-ma.js index 29007412f..a0e803c08 100644 --- a/src/locale/ar-ma.js +++ b/src/locale/ar-ma.js @@ -1,3 +1,4 @@ +// Arabic (Morocco) [ar-ma] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-sa.js b/src/locale/ar-sa.js index a619272e4..fd28501fc 100644 --- a/src/locale/ar-sa.js +++ b/src/locale/ar-sa.js @@ -1,3 +1,4 @@ +// Arabic (Saudi Arabia) [ar-sa] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar-tn.js b/src/locale/ar-tn.js index 96b804c59..99fcff2de 100644 --- a/src/locale/ar-tn.js +++ b/src/locale/ar-tn.js @@ -1,3 +1,4 @@ +// Arabic (Tunisia) [ar-tn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ar.js b/src/locale/ar.js index 2acb0652a..0db8d0340 100644 --- a/src/locale/ar.js +++ b/src/locale/ar.js @@ -1,3 +1,4 @@ +// Arabic [ar] import dayjs from 'dayjs' const months = 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_') diff --git a/src/locale/az.js b/src/locale/az.js index c24f1b49c..c6c608e6d 100644 --- a/src/locale/az.js +++ b/src/locale/az.js @@ -1,3 +1,4 @@ +// Azerbaijani [az] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/be.js b/src/locale/be.js index 80b47dd2c..3b4e2d731 100644 --- a/src/locale/be.js +++ b/src/locale/be.js @@ -1,3 +1,4 @@ +// Belarusian [be] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/bg.js b/src/locale/bg.js index 96438dd90..c6edd11c3 100644 --- a/src/locale/bg.js +++ b/src/locale/bg.js @@ -1,3 +1,4 @@ +// Bulgarian [bg] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/bi.js b/src/locale/bi.js new file mode 100644 index 000000000..7f6cbecba --- /dev/null +++ b/src/locale/bi.js @@ -0,0 +1,39 @@ +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 diff --git a/src/locale/bm.js b/src/locale/bm.js index a8134cf03..3c2794c6e 100644 --- a/src/locale/bm.js +++ b/src/locale/bm.js @@ -1,3 +1,4 @@ +// Bambara [bm] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/bn.js b/src/locale/bn.js index efed438a4..415b508b1 100644 --- a/src/locale/bn.js +++ b/src/locale/bn.js @@ -1,3 +1,4 @@ +// Bengali [bn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/bo.js b/src/locale/bo.js index 9f213cb78..1e939b12c 100644 --- a/src/locale/bo.js +++ b/src/locale/bo.js @@ -1,3 +1,4 @@ +// Tibetan [bo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/br.js b/src/locale/br.js index 77cca1515..57d7d4f70 100644 --- a/src/locale/br.js +++ b/src/locale/br.js @@ -1,3 +1,4 @@ +// Breton [br] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/bs.js b/src/locale/bs.js index 18bf21923..e30bcd293 100644 --- a/src/locale/bs.js +++ b/src/locale/bs.js @@ -1,3 +1,4 @@ +// Bosnian [bs] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ca.js b/src/locale/ca.js index c6469085b..0046871d6 100644 --- a/src/locale/ca.js +++ b/src/locale/ca.js @@ -1,3 +1,4 @@ +// Catalan [ca] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/cs.js b/src/locale/cs.js index 1c44b31e3..ee3c70ffe 100644 --- a/src/locale/cs.js +++ b/src/locale/cs.js @@ -1,3 +1,4 @@ +// Czech [cs] import dayjs from 'dayjs' function plural(n) { diff --git a/src/locale/cv.js b/src/locale/cv.js index 37f44c64d..812f6a5ff 100644 --- a/src/locale/cv.js +++ b/src/locale/cv.js @@ -1,3 +1,4 @@ +// Chuvash [cv] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/cy.js b/src/locale/cy.js index 482a44108..c9333504c 100644 --- a/src/locale/cy.js +++ b/src/locale/cy.js @@ -1,3 +1,4 @@ +// Welsh [cy] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/da.js b/src/locale/da.js index df38f78b3..0b5709f0e 100644 --- a/src/locale/da.js +++ b/src/locale/da.js @@ -1,3 +1,4 @@ +// Danish [da] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/de-at.js b/src/locale/de-at.js index 52a192ec5..db932d078 100644 --- a/src/locale/de-at.js +++ b/src/locale/de-at.js @@ -1,3 +1,4 @@ +// German (Austria) [de-at] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/de-ch.js b/src/locale/de-ch.js index c4746cbc4..2c4b94d02 100644 --- a/src/locale/de-ch.js +++ b/src/locale/de-ch.js @@ -1,3 +1,4 @@ +// German (Switzerland) [de-ch] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/de.js b/src/locale/de.js index 13013d0cc..1478c3704 100644 --- a/src/locale/de.js +++ b/src/locale/de.js @@ -1,3 +1,4 @@ +// German [de] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/dv.js b/src/locale/dv.js index 2aa5b675b..897d7af04 100644 --- a/src/locale/dv.js +++ b/src/locale/dv.js @@ -1,3 +1,4 @@ +// Maldivian [dv] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/el.js b/src/locale/el.js index f6aa7a70e..4c23b2f48 100644 --- a/src/locale/el.js +++ b/src/locale/el.js @@ -1,3 +1,4 @@ +// Greek [el] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-SG.js b/src/locale/en-SG.js index 50aed63a5..a845024f7 100644 --- a/src/locale/en-SG.js +++ b/src/locale/en-SG.js @@ -1,3 +1,4 @@ +// English (Singapore) [en-sg] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-au.js b/src/locale/en-au.js index 71cba308c..90c83c423 100644 --- a/src/locale/en-au.js +++ b/src/locale/en-au.js @@ -1,3 +1,4 @@ +// English (Australia) [en-au] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-ca.js b/src/locale/en-ca.js index 4c9b59eb7..6517e00e7 100644 --- a/src/locale/en-ca.js +++ b/src/locale/en-ca.js @@ -1,3 +1,4 @@ +// English (Canada) [en-ca] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-gb.js b/src/locale/en-gb.js index dfa84d2cc..3117ae577 100644 --- a/src/locale/en-gb.js +++ b/src/locale/en-gb.js @@ -1,3 +1,4 @@ +// English (United Kingdom) [en-gb] import dayjs from 'dayjs' const locale = { @@ -8,6 +9,7 @@ const locale = { 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', diff --git a/src/locale/en-ie.js b/src/locale/en-ie.js index 94e592c20..5116c251d 100644 --- a/src/locale/en-ie.js +++ b/src/locale/en-ie.js @@ -1,3 +1,4 @@ +// English (Ireland) [en-ie] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-il.js b/src/locale/en-il.js index e8787cc4e..d19d82008 100644 --- a/src/locale/en-il.js +++ b/src/locale/en-il.js @@ -1,3 +1,4 @@ +// English (Israel) [en-il] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/en-nz.js b/src/locale/en-nz.js index 190d8974a..01abae249 100644 --- a/src/locale/en-nz.js +++ b/src/locale/en-nz.js @@ -1,3 +1,4 @@ +// English (New Zealand) [en-nz] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/eo.js b/src/locale/eo.js index 9d3231e6b..f7f54c538 100644 --- a/src/locale/eo.js +++ b/src/locale/eo.js @@ -1,3 +1,4 @@ +// Esperanto [eo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/es-do.js b/src/locale/es-do.js index bb680ab3b..45002d07b 100644 --- a/src/locale/es-do.js +++ b/src/locale/es-do.js @@ -1,3 +1,4 @@ +// Spanish (Dominican Republic) [es-do] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/es-us.js b/src/locale/es-us.js index 65959b70a..cc81c4843 100644 --- a/src/locale/es-us.js +++ b/src/locale/es-us.js @@ -1,3 +1,4 @@ +// Spanish (United States) [es-us] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/es.js b/src/locale/es.js index 4cb487f47..951e7f531 100644 --- a/src/locale/es.js +++ b/src/locale/es.js @@ -1,3 +1,4 @@ +// Spanish [es] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/et.js b/src/locale/et.js index b9d8e18e4..8a9ad1e70 100644 --- a/src/locale/et.js +++ b/src/locale/et.js @@ -1,5 +1,25 @@ +// 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 @@ -9,28 +29,20 @@ const locale = { monthsShort: 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'), ordinal: n => `${n}.`, weekStart: 1, - /* - * This relativeTime is currently configured for having proper past - * tense forms since Estonian needs a separate version for future tense - * and I think past tense is a more common use case for this kind of library. - * - * Doing this properly requires this issue to be fixed: - * https://github.com/iamkun/dayjs/issues/302 - */ relativeTime: { future: '%s pärast', past: '%s tagasi', - s: 'mõni sekund', // for past tense - m: 'minut', // for past tense - mm: '%d minutit', // for past tense - h: 'tund', // for past tense - hh: '%d tundi', // for past tense - d: 'päev', // for past tense - dd: '%d päeva', // for past tense - M: 'kuu', // for past tense - MM: '%d kuud', // for past tense - y: 'aasta', // for past tense - yy: '%d aastat' // for past tense + 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', diff --git a/src/locale/eu.js b/src/locale/eu.js index 3433a75ca..d85763939 100644 --- a/src/locale/eu.js +++ b/src/locale/eu.js @@ -1,3 +1,4 @@ +// Basque [eu] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fa.js b/src/locale/fa.js index 1c2ddad12..cf338279f 100644 --- a/src/locale/fa.js +++ b/src/locale/fa.js @@ -1,3 +1,4 @@ +// Persian [fa] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fi.js b/src/locale/fi.js index 238636b22..3e7103eb4 100644 --- a/src/locale/fi.js +++ b/src/locale/fi.js @@ -1,3 +1,4 @@ +// Finnish [fi] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fo.js b/src/locale/fo.js index c51dcb36a..f3c2ce48e 100644 --- a/src/locale/fo.js +++ b/src/locale/fo.js @@ -1,3 +1,4 @@ +// Faroese [fo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fr-ca.js b/src/locale/fr-ca.js index b03ba84bf..b3e965028 100644 --- a/src/locale/fr-ca.js +++ b/src/locale/fr-ca.js @@ -1,3 +1,4 @@ +// French (Canada) [fr-ca] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fr-ch.js b/src/locale/fr-ch.js index e917818f2..c1395c457 100644 --- a/src/locale/fr-ch.js +++ b/src/locale/fr-ch.js @@ -1,3 +1,4 @@ +// French (Switzerland) [fr-ch] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fr.js b/src/locale/fr.js index 20b7cfe3c..72290622a 100644 --- a/src/locale/fr.js +++ b/src/locale/fr.js @@ -1,3 +1,4 @@ +// French [fr] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/fy.js b/src/locale/fy.js index 2bff3e14a..dd0837b5f 100644 --- a/src/locale/fy.js +++ b/src/locale/fy.js @@ -1,3 +1,4 @@ +// Frisian [fy] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ga.js b/src/locale/ga.js index 36a8bb670..1e433cddf 100644 --- a/src/locale/ga.js +++ b/src/locale/ga.js @@ -1,3 +1,4 @@ +// Irish or Irish Gaelic [ga] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/gd.js b/src/locale/gd.js index bca103290..02df81a41 100644 --- a/src/locale/gd.js +++ b/src/locale/gd.js @@ -1,3 +1,4 @@ +// Scottish Gaelic [gd] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/gl.js b/src/locale/gl.js index e9f1bb478..77f2dbb66 100644 --- a/src/locale/gl.js +++ b/src/locale/gl.js @@ -1,3 +1,4 @@ +// Galician [gl] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/gom-latn.js b/src/locale/gom-latn.js index 44b049dae..519452574 100644 --- a/src/locale/gom-latn.js +++ b/src/locale/gom-latn.js @@ -1,3 +1,4 @@ +// Konkani Latin script [gom-latn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/gu.js b/src/locale/gu.js index cef554545..5dd03842a 100644 --- a/src/locale/gu.js +++ b/src/locale/gu.js @@ -1,3 +1,4 @@ +// Gujarati [gu] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/he.js b/src/locale/he.js index 984b4fe13..c2a641e65 100644 --- a/src/locale/he.js +++ b/src/locale/he.js @@ -1,3 +1,4 @@ +// Hebrew [he] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/hi.js b/src/locale/hi.js index d303175fd..52e90c5ab 100644 --- a/src/locale/hi.js +++ b/src/locale/hi.js @@ -1,3 +1,4 @@ +// Hindi [hi] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/hr.js b/src/locale/hr.js index 22e962756..113c1631f 100644 --- a/src/locale/hr.js +++ b/src/locale/hr.js @@ -1,3 +1,4 @@ +// Croatian [hr] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/hu.js b/src/locale/hu.js index 98ca649e4..116086da6 100644 --- a/src/locale/hu.js +++ b/src/locale/hu.js @@ -1,3 +1,4 @@ +// Hungarian [hu] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/hy-am.js b/src/locale/hy-am.js index f8440bc8b..acebd756a 100644 --- a/src/locale/hy-am.js +++ b/src/locale/hy-am.js @@ -1,3 +1,4 @@ +// Armenian [hy-am] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/id.js b/src/locale/id.js index 32175f4a3..bdae85a4a 100644 --- a/src/locale/id.js +++ b/src/locale/id.js @@ -1,3 +1,4 @@ +// Indonesian [id] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/is.js b/src/locale/is.js index 300e07c60..7b1409e67 100644 --- a/src/locale/is.js +++ b/src/locale/is.js @@ -1,3 +1,4 @@ +// Icelandic [is] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/it-ch.js b/src/locale/it-ch.js index b007df64d..b71bdc323 100644 --- a/src/locale/it-ch.js +++ b/src/locale/it-ch.js @@ -1,3 +1,4 @@ +// Italian (Switzerland) [it-ch] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/it.js b/src/locale/it.js index d0cdbe313..08f660bef 100644 --- a/src/locale/it.js +++ b/src/locale/it.js @@ -1,3 +1,4 @@ +// Italian [it] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ja.js b/src/locale/ja.js index dd206b198..111d7d38d 100644 --- a/src/locale/ja.js +++ b/src/locale/ja.js @@ -1,3 +1,4 @@ +// Japanese [ja] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/jv.js b/src/locale/jv.js index 046c5899e..37d0a9292 100644 --- a/src/locale/jv.js +++ b/src/locale/jv.js @@ -1,3 +1,4 @@ +// Javanese [jv] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ka.js b/src/locale/ka.js index cc2da72ad..3410176ec 100644 --- a/src/locale/ka.js +++ b/src/locale/ka.js @@ -1,3 +1,4 @@ +// Georgian [ka] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/kk.js b/src/locale/kk.js index 0cec380da..4474f6e55 100644 --- a/src/locale/kk.js +++ b/src/locale/kk.js @@ -1,3 +1,4 @@ +// Kazakh [kk] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/km.js b/src/locale/km.js index 424ff919b..91c942fa6 100644 --- a/src/locale/km.js +++ b/src/locale/km.js @@ -1,3 +1,4 @@ +// Cambodian [km] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/kn.js b/src/locale/kn.js index ba214ba0a..df173b6e8 100644 --- a/src/locale/kn.js +++ b/src/locale/kn.js @@ -1,3 +1,4 @@ +// Kannada [kn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ko.js b/src/locale/ko.js index cbb3c81c7..8a8e8ea9b 100644 --- a/src/locale/ko.js +++ b/src/locale/ko.js @@ -1,3 +1,4 @@ +// Korean [ko] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ku.js b/src/locale/ku.js index 66fb60ac1..5f1ce6a60 100644 --- a/src/locale/ku.js +++ b/src/locale/ku.js @@ -1,3 +1,4 @@ +// Kurdish [ku] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ky.js b/src/locale/ky.js index 417df4ccc..8a373e585 100644 --- a/src/locale/ky.js +++ b/src/locale/ky.js @@ -1,3 +1,4 @@ +// Kyrgyz [ky] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/lb.js b/src/locale/lb.js index 533ee733e..a36fc326a 100644 --- a/src/locale/lb.js +++ b/src/locale/lb.js @@ -1,3 +1,4 @@ +// Luxembourgish [lb] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/lo.js b/src/locale/lo.js index 7a4eafcbf..5892627cf 100644 --- a/src/locale/lo.js +++ b/src/locale/lo.js @@ -1,3 +1,4 @@ +// Lao [lo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/lt.js b/src/locale/lt.js index 319f63db0..7876d87b0 100644 --- a/src/locale/lt.js +++ b/src/locale/lt.js @@ -1,3 +1,4 @@ +// Lithuanian [lt] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/lv.js b/src/locale/lv.js index 55abd9635..b06bd65a9 100644 --- a/src/locale/lv.js +++ b/src/locale/lv.js @@ -1,3 +1,4 @@ +// Latvian [lv] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/me.js b/src/locale/me.js index d0cad96ef..8d044326c 100644 --- a/src/locale/me.js +++ b/src/locale/me.js @@ -1,3 +1,4 @@ +// Montenegrin [me] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/mi.js b/src/locale/mi.js index 443d13aaa..de7e76595 100644 --- a/src/locale/mi.js +++ b/src/locale/mi.js @@ -1,3 +1,4 @@ +// Maori [mi] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/mk.js b/src/locale/mk.js index 0029b9144..3e29cb9e0 100644 --- a/src/locale/mk.js +++ b/src/locale/mk.js @@ -1,3 +1,4 @@ +// Macedonian [mk] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ml.js b/src/locale/ml.js index fc1ec2cf3..f080d888b 100644 --- a/src/locale/ml.js +++ b/src/locale/ml.js @@ -1,3 +1,4 @@ +// Malayalam [ml] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/mn.js b/src/locale/mn.js index 3c6d8f435..2f60db716 100644 --- a/src/locale/mn.js +++ b/src/locale/mn.js @@ -1,3 +1,4 @@ +// Mongolian [mn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/mr.js b/src/locale/mr.js index d58ed4ee0..01537e8b5 100644 --- a/src/locale/mr.js +++ b/src/locale/mr.js @@ -1,3 +1,4 @@ +// Marathi [mr] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ms-my.js b/src/locale/ms-my.js index 225dc1485..11e44496d 100644 --- a/src/locale/ms-my.js +++ b/src/locale/ms-my.js @@ -1,3 +1,4 @@ +// Malay [ms-my] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ms.js b/src/locale/ms.js index 0cd50d9b4..4c4fea9cc 100644 --- a/src/locale/ms.js +++ b/src/locale/ms.js @@ -1,3 +1,4 @@ +// Malay [ms] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/mt.js b/src/locale/mt.js index b339413ed..f946e085d 100644 --- a/src/locale/mt.js +++ b/src/locale/mt.js @@ -1,3 +1,4 @@ +// Maltese (Malta) [mt] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/my.js b/src/locale/my.js index 3ba8999c8..9aed9700c 100644 --- a/src/locale/my.js +++ b/src/locale/my.js @@ -1,3 +1,4 @@ +// Burmese [my] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/nb.js b/src/locale/nb.js index 2dd5b0a09..e9614dcf5 100644 --- a/src/locale/nb.js +++ b/src/locale/nb.js @@ -1,3 +1,4 @@ +// Norwegian Bokmål [nb] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ne.js b/src/locale/ne.js index 75b508782..a7f5f13b4 100644 --- a/src/locale/ne.js +++ b/src/locale/ne.js @@ -1,3 +1,4 @@ +// Nepalese [ne] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/nl-be.js b/src/locale/nl-be.js index e86dd4f15..941fd18e3 100644 --- a/src/locale/nl-be.js +++ b/src/locale/nl-be.js @@ -1,3 +1,4 @@ +// Dutch (Belgium) [nl-be] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/nl.js b/src/locale/nl.js index 9466c53ba..57f226068 100644 --- a/src/locale/nl.js +++ b/src/locale/nl.js @@ -1,3 +1,4 @@ +// Dutch [nl] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/nn.js b/src/locale/nn.js index c48e22b49..55d26ead6 100644 --- a/src/locale/nn.js +++ b/src/locale/nn.js @@ -1,3 +1,4 @@ +// Nynorsk [nn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/oc-lnc.js b/src/locale/oc-lnc.js index f4ef9aab7..4ec851167 100644 --- a/src/locale/oc-lnc.js +++ b/src/locale/oc-lnc.js @@ -1,3 +1,4 @@ +// Occitan, lengadocian dialecte [oc-lnc] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/pa-in.js b/src/locale/pa-in.js index a24563466..174423ce8 100644 --- a/src/locale/pa-in.js +++ b/src/locale/pa-in.js @@ -1,3 +1,4 @@ +// Punjabi (India) [pa-in] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/pl.js b/src/locale/pl.js index c1788f249..c886f584f 100644 --- a/src/locale/pl.js +++ b/src/locale/pl.js @@ -1,5 +1,28 @@ +// 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 locale = { name: 'pl', weekdays: 'Niedziela_Poniedziałek_Wtorek_Środa_Czwartek_Piątek_Sobota'.split('_'), @@ -11,18 +34,18 @@ const locale = { weekStart: 1, relativeTime: { future: 'za %s', - past: 'po %s', + past: '%s temu', s: 'kilka sekund', - m: 'minuta', - mm: '%d minut', - h: 'godzina', - hh: '%d godzin', - d: 'dzień', + m: translate, + mm: translate, + h: translate, + hh: translate, + d: '1 dzień', dd: '%d dni', M: 'miesiąc', - MM: '%d miesięcy', + MM: translate, y: 'rok', - yy: '%d lat' + yy: translate }, formats: { LT: 'HH:mm', diff --git a/src/locale/pt-br.js b/src/locale/pt-br.js index 3a0c1b033..215f96481 100644 --- a/src/locale/pt-br.js +++ b/src/locale/pt-br.js @@ -1,3 +1,4 @@ +// Portuguese (Brazil) [pt-br] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/pt.js b/src/locale/pt.js index 2f5216c5d..5ed2129d5 100644 --- a/src/locale/pt.js +++ b/src/locale/pt.js @@ -1,3 +1,4 @@ +// Portuguese [pt] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ro.js b/src/locale/ro.js index 99a975d9d..7a7e1f22a 100644 --- a/src/locale/ro.js +++ b/src/locale/ro.js @@ -1,3 +1,4 @@ +// Romanian [ro] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ru.js b/src/locale/ru.js index 9b5d6d4b8..8a6533b64 100644 --- a/src/locale/ru.js +++ b/src/locale/ru.js @@ -1,3 +1,4 @@ +// Russian [ru] import dayjs from 'dayjs' const monthFormat = 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_') diff --git a/src/locale/sd.js b/src/locale/sd.js index e781057e2..f56a72adb 100644 --- a/src/locale/sd.js +++ b/src/locale/sd.js @@ -1,3 +1,4 @@ +// Sindhi [sd] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/se.js b/src/locale/se.js index 9c453f1df..d6e4bc968 100644 --- a/src/locale/se.js +++ b/src/locale/se.js @@ -1,3 +1,4 @@ +// Northern Sami [se] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/si.js b/src/locale/si.js index 1981031e2..fcd685120 100644 --- a/src/locale/si.js +++ b/src/locale/si.js @@ -1,3 +1,4 @@ +// Sinhalese [si] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sk.js b/src/locale/sk.js index ce01f431e..acbb10598 100644 --- a/src/locale/sk.js +++ b/src/locale/sk.js @@ -1,3 +1,4 @@ +// Slovak [sk] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sl.js b/src/locale/sl.js index d5cb073bd..edac5dd5e 100644 --- a/src/locale/sl.js +++ b/src/locale/sl.js @@ -1,3 +1,4 @@ +// Slovenian [sl] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sq.js b/src/locale/sq.js index ef3f2a890..b347a7aa8 100644 --- a/src/locale/sq.js +++ b/src/locale/sq.js @@ -1,3 +1,4 @@ +// Albanian [sq] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sr-cyrl.js b/src/locale/sr-cyrl.js index c1950cca7..019544dac 100644 --- a/src/locale/sr-cyrl.js +++ b/src/locale/sr-cyrl.js @@ -1,3 +1,4 @@ +// Serbian Cyrillic [sr-cyrl] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sr.js b/src/locale/sr.js index 6578290a3..ca0cb47fb 100644 --- a/src/locale/sr.js +++ b/src/locale/sr.js @@ -1,3 +1,4 @@ +// Serbian [sr] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ss.js b/src/locale/ss.js index 2a564edee..fc52ec25a 100644 --- a/src/locale/ss.js +++ b/src/locale/ss.js @@ -1,3 +1,4 @@ +// siSwati [ss] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sv.js b/src/locale/sv.js index cd2d46451..493e3152a 100644 --- a/src/locale/sv.js +++ b/src/locale/sv.js @@ -1,3 +1,4 @@ +// Swedish [sv] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/sw.js b/src/locale/sw.js index 4b05ace96..a48dd2eea 100644 --- a/src/locale/sw.js +++ b/src/locale/sw.js @@ -1,3 +1,4 @@ +// Swahili [sw] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ta.js b/src/locale/ta.js index 9498a73fe..87db359a9 100644 --- a/src/locale/ta.js +++ b/src/locale/ta.js @@ -1,3 +1,4 @@ +// Tamil [ta] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/te.js b/src/locale/te.js index b2970b5f2..2c7424d29 100644 --- a/src/locale/te.js +++ b/src/locale/te.js @@ -1,3 +1,4 @@ +// Telugu [te] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tet.js b/src/locale/tet.js index 1ecb53294..e421ee487 100644 --- a/src/locale/tet.js +++ b/src/locale/tet.js @@ -1,3 +1,4 @@ +// Tetun Dili (East Timor) [tet] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tg.js b/src/locale/tg.js index a789c344b..9399608e2 100644 --- a/src/locale/tg.js +++ b/src/locale/tg.js @@ -1,3 +1,4 @@ +// Tajik [tg] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/th.js b/src/locale/th.js index 93b1dba81..3b4d685aa 100644 --- a/src/locale/th.js +++ b/src/locale/th.js @@ -1,3 +1,4 @@ +// Thai [th] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tl-ph.js b/src/locale/tl-ph.js index e8023845f..2b96cd7c3 100644 --- a/src/locale/tl-ph.js +++ b/src/locale/tl-ph.js @@ -1,3 +1,4 @@ +// Tagalog (Philippines) [tl-ph] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tlh.js b/src/locale/tlh.js index c62eeccdd..c4280fd4f 100644 --- a/src/locale/tlh.js +++ b/src/locale/tlh.js @@ -1,3 +1,4 @@ +// Klingon [tlh] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tr.js b/src/locale/tr.js index 281983283..389ec5ac2 100644 --- a/src/locale/tr.js +++ b/src/locale/tr.js @@ -1,3 +1,4 @@ +// Turkish [tr] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tzl.js b/src/locale/tzl.js index 5c6dc8876..b2890ee12 100644 --- a/src/locale/tzl.js +++ b/src/locale/tzl.js @@ -1,3 +1,4 @@ +// Talossan [tzl] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tzm-latn.js b/src/locale/tzm-latn.js index 529e55b2c..aa6fc9a16 100644 --- a/src/locale/tzm-latn.js +++ b/src/locale/tzm-latn.js @@ -1,3 +1,4 @@ +// Central Atlas Tamazight Latin [tzm-latn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/tzm.js b/src/locale/tzm.js index 5c75ea543..8718f35e8 100644 --- a/src/locale/tzm.js +++ b/src/locale/tzm.js @@ -1,3 +1,4 @@ +// Central Atlas Tamazight [tzm] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/ug-cn.js b/src/locale/ug-cn.js index 405d41066..08a0ffd6d 100644 --- a/src/locale/ug-cn.js +++ b/src/locale/ug-cn.js @@ -1,3 +1,4 @@ +// Uyghur (China) [ug-cn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/uk.js b/src/locale/uk.js index 45d4b0c04..4cfa84d8b 100644 --- a/src/locale/uk.js +++ b/src/locale/uk.js @@ -1,3 +1,4 @@ +// Ukrainian [uk] import dayjs from 'dayjs' function plural(word, num) { diff --git a/src/locale/ur.js b/src/locale/ur.js index c4a5e52f1..797d9c157 100644 --- a/src/locale/ur.js +++ b/src/locale/ur.js @@ -1,3 +1,4 @@ +// Urdu [ur] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/uz-latn.js b/src/locale/uz-latn.js index 6adaf96f3..220d5d44c 100644 --- a/src/locale/uz-latn.js +++ b/src/locale/uz-latn.js @@ -1,3 +1,4 @@ +// Uzbek Latin [uz-latn] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/uz.js b/src/locale/uz.js index 2f6327c40..23f4042eb 100644 --- a/src/locale/uz.js +++ b/src/locale/uz.js @@ -1,3 +1,4 @@ +// Uzbek [uz] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/vi.js b/src/locale/vi.js index 8b915aac8..63d0aaf5d 100644 --- a/src/locale/vi.js +++ b/src/locale/vi.js @@ -1,3 +1,4 @@ +// Vietnamese [vi] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/x-pseudo.js b/src/locale/x-pseudo.js index 7cc06374f..b19b5fb48 100644 --- a/src/locale/x-pseudo.js +++ b/src/locale/x-pseudo.js @@ -1,3 +1,4 @@ +// Pseudo [x-pseudo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/yo.js b/src/locale/yo.js index c1884a28e..e5264a8b8 100644 --- a/src/locale/yo.js +++ b/src/locale/yo.js @@ -1,3 +1,4 @@ +// Yoruba Nigeria [yo] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/zh-cn.js b/src/locale/zh-cn.js index f15951751..3034d4404 100644 --- a/src/locale/zh-cn.js +++ b/src/locale/zh-cn.js @@ -1,3 +1,4 @@ +// Chinese (China) [zh-cn] import dayjs from 'dayjs' const locale = { @@ -16,6 +17,7 @@ const locale = { } }, weekStart: 1, + yearStart: 4, formats: { LT: 'HH:mm', LTS: 'HH:mm:ss', diff --git a/src/locale/zh-hk.js b/src/locale/zh-hk.js index 042d88867..3c38d0756 100644 --- a/src/locale/zh-hk.js +++ b/src/locale/zh-hk.js @@ -1,3 +1,4 @@ +// Chinese (Hong Kong) [zh-hk] import dayjs from 'dayjs' const locale = { diff --git a/src/locale/zh-tw.js b/src/locale/zh-tw.js index f931c0a51..b7880674d 100644 --- a/src/locale/zh-tw.js +++ b/src/locale/zh-tw.js @@ -1,3 +1,4 @@ +// Chinese (Taiwan) [zh-tw] import dayjs from 'dayjs' const locale = { diff --git a/src/plugin/localeData/index.js b/src/plugin/localeData/index.js index 329090d24..b6da1ca78 100644 --- a/src/plugin/localeData/index.js +++ b/src/plugin/localeData/index.js @@ -1,12 +1,13 @@ export default (o, c, dayjs) => { // locale needed later const proto = c.prototype const getShort = (ins, target, full, num) => { - const locale = ins.$locale() + const locale = ins.name ? ins : ins.$locale() if (!locale[target]) { return locale[full].map(f => f.substr(0, num)) } return locale[target] } + const getDayjsLocaleObject = () => dayjs.Ls[dayjs.locale()] const localeData = function () { return { months: instance => @@ -26,9 +27,24 @@ export default (o, c, dayjs) => { // locale needed later } dayjs.localeData = () => { - const localeObject = dayjs.Ls[dayjs.locale()] + const localeObject = getDayjsLocaleObject() return { - firstDayOfWeek: () => localeObject.weekStart || 0 + firstDayOfWeek: () => localeObject.weekStart || 0, + weekdays: () => dayjs.weekdays(), + weekdaysShort: () => dayjs.weekdaysShort(), + weekdaysMin: () => dayjs.weekdaysMin(), + months: () => dayjs.months(), + monthsShort: () => dayjs.monthsShort() } } + + dayjs.months = () => getDayjsLocaleObject().months + + dayjs.monthsShort = () => getShort(getDayjsLocaleObject(), 'monthsShort', 'months', 3) + + dayjs.weekdays = () => getDayjsLocaleObject().weekdays + + dayjs.weekdaysShort = () => getShort(getDayjsLocaleObject(), 'weekdaysShort', 'weekdays', 3) + + dayjs.weekdaysMin = () => getShort(getDayjsLocaleObject(), 'weekdaysMin', 'weekdays', 2) } diff --git a/src/plugin/weekOfYear/index.js b/src/plugin/weekOfYear/index.js index 7251d5af4..f0c6088d4 100644 --- a/src/plugin/weekOfYear/index.js +++ b/src/plugin/weekOfYear/index.js @@ -1,17 +1,26 @@ import { MS, Y, D, W } from '../../constant' -export default (o, c, d) => { +export default (o, c) => { const proto = c.prototype proto.week = function (week = null) { if (week !== null) { - return this.add((week - this.week()) * 7, 'day') + return this.add((week - this.week()) * 7, D) } - const weekStart = this.$locale().weekStart || 0 - const startOfYear = d(this).startOf(Y) - const compareDay = startOfYear.subtract(startOfYear.day() - weekStart, D).subtract(1, MS) - const diffInWeek = this.diff(compareDay, W, true) - const result = Math.ceil(diffInWeek) - return result > 52 ? 1 : result + const yearStart = this.$locale().yearStart || 1 + if (this.month() === 11 && this.date() > 25) { + const nextYearStartDay = this.startOf(Y).add(1, Y).date(yearStart) + const thisEndOfWeek = this.endOf(W) + if (nextYearStartDay.isBefore(thisEndOfWeek)) { + return 1 + } + } + const yearStartDay = this.startOf(Y).date(yearStart) + const yearStartWeek = yearStartDay.startOf(W).subtract(1, MS) + const diffInWeek = this.diff(yearStartWeek, W, true) + if (diffInWeek < 0) { + return this.startOf('week').week() + } + return Math.ceil(diffInWeek) } proto.weeks = function (week = null) { diff --git a/test/locale/et.test.js b/test/locale/et.test.js new file mode 100644 index 000000000..5b8b75833 --- /dev/null +++ b/test/locale/et.test.js @@ -0,0 +1,38 @@ +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)) + }) +}) diff --git a/test/locale/keys.test.js b/test/locale/keys.test.js index a06960a31..5def0014e 100644 --- a/test/locale/keys.test.js +++ b/test/locale/keys.test.js @@ -28,6 +28,7 @@ Locale.forEach((locale) => { monthsShort, weekdaysMin, weekStart, + yearStart, meridiem } = locale.content @@ -37,6 +38,7 @@ Locale.forEach((locale) => { 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)) { diff --git a/test/locale/pl.test.js b/test/locale/pl.test.js new file mode 100644 index 000000000..6e43450c5 --- /dev/null +++ b/test/locale/pl.test.js @@ -0,0 +1,47 @@ +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('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)) + }) +}) diff --git a/test/plugin/localeData.test.js b/test/plugin/localeData.test.js index 289832873..28d667a02 100644 --- a/test/plugin/localeData.test.js +++ b/test/plugin/localeData.test.js @@ -38,14 +38,29 @@ it('Instance localeData', () => { it('Global localeData', () => { - dayjs.locale('zh-cn') - moment.locale('zh-cn') - let dayjsLocaleData = dayjs.localeData() - let momentLocaleData = moment.localeData() - expect(dayjsLocaleData.firstDayOfWeek()).toBe(momentLocaleData.firstDayOfWeek()) - dayjs.locale('en') - moment.locale('en') - dayjsLocaleData = dayjs.localeData() - momentLocaleData = moment.localeData() - expect(dayjsLocaleData.firstDayOfWeek()).toBe(momentLocaleData.firstDayOfWeek()) + ['zh-cn', 'en'].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()) + }) +}) + + +it('Listing the months and weekdays', () => { + ['zh-cn', 'en'].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()) + }) }) diff --git a/test/plugin/weekOfYear.test.js b/test/plugin/weekOfYear.test.js index 980b4bc77..576b0c785 100644 --- a/test/plugin/weekOfYear.test.js +++ b/test/plugin/weekOfYear.test.js @@ -33,14 +33,25 @@ it('Week of year', () => { 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()) +}) - // Edges - expect(dayjs('2018-12-30').week()).toBe(moment('2018-12-30').week()) - expect(dayjs('2019-12-29').week()).toBe(moment('2019-12-29').week()) - expect(dayjs('2019-12-30').week()).toBe(moment('2019-12-30').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', () => { diff --git a/test/plugin/weekday.test.js b/test/plugin/weekday.test.js index 703f3ec84..52b7a938f 100644 --- a/test/plugin/weekday.test.js +++ b/test/plugin/weekday.test.js @@ -31,6 +31,10 @@ it('Monday is the first day of the week', () => { 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', () => {