Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: iamkun/dayjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.19
Choose a base ref
...
head repository: iamkun/dayjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.8.20
Choose a head ref
  • 10 commits
  • 144 files changed
  • 4 contributors

Commits on Jan 11, 2020

  1. Copy the full SHA
    f00db36 View commit details

Commits on Jan 19, 2020

  1. fix: Add Bislama Locale (bi) (#780)

    michaeltoohig authored and iamkun committed Jan 19, 2020
    Copy the full SHA
    9ac6ab4 View commit details
  2. Copy the full SHA
    d372475 View commit details
  3. chore: Add locale comment

    iamkun committed Jan 19, 2020
    Copy the full SHA
    267da1b View commit details
  4. Merge pull request #781 from iamkun/fix/locale-update

    chore: merge locale update PR
    iamkun authored Jan 19, 2020
    Copy the full SHA
    a4979c7 View commit details
  5. Copy the full SHA
    287fed6 View commit details
  6. Copy the full SHA
    144c2ae View commit details

Commits on Jan 30, 2020

  1. Copy the full SHA
    d8e0f45 View commit details

Commits on Feb 4, 2020

  1. Merge pull request #793 from iamkun/dev

    D2M
    iamkun authored Feb 4, 2020
    Copy the full SHA
    372b253 View commit details
  2. chore(release): 1.8.20 [skip ci]

    ## [1.8.20](v1.8.19...v1.8.20) (2020-02-04)
    
    ### Bug Fixes
    
    * Add Bislama Locale (bi) ([#780](#780)) ([9ac6ab4](9ac6ab4))
    * Fix weekOfYear plugin to support yearStart locale for better week number result ([#769](#769)) ([f00db36](f00db36))
    * Update et (Estonian) locale relativeTime ([#790](#790)) ([d8e0f45](d8e0f45))
    * Update LocaleData plugin to support dayjs.localeData().weekdays() API ([287fed6](287fed6)), closes [#779](#779)
    * Update LocaleData plugin to support dayjs.months dayjs.weekdays API ([144c2ae](144c2ae)), closes [#779](#779)
    * Update pl locale fusional config ([d372475](d372475))
    semantic-release-bot committed Feb 4, 2020
    Copy the full SHA
    0c385e1 View commit details
Showing with 416 additions and 53 deletions.
  1. +12 −0 CHANGELOG.md
  2. +1 −0 docs/en/I18n.md
  3. +2 −0 docs/es-es/I18n.md
  4. +1 −0 docs/ja/I18n.md
  5. +1 −0 docs/ko/I18n.md
  6. +1 −0 docs/pt-br/I18n.md
  7. +1 −0 docs/zh-cn/I18n.md
  8. +1 −0 src/locale/af.js
  9. +1 −0 src/locale/ar-dz.js
  10. +1 −0 src/locale/ar-kw.js
  11. +1 −0 src/locale/ar-ly.js
  12. +1 −0 src/locale/ar-ma.js
  13. +1 −0 src/locale/ar-sa.js
  14. +1 −0 src/locale/ar-tn.js
  15. +1 −0 src/locale/ar.js
  16. +1 −0 src/locale/az.js
  17. +1 −0 src/locale/be.js
  18. +1 −0 src/locale/bg.js
  19. +39 −0 src/locale/bi.js
  20. +1 −0 src/locale/bm.js
  21. +1 −0 src/locale/bn.js
  22. +1 −0 src/locale/bo.js
  23. +1 −0 src/locale/br.js
  24. +1 −0 src/locale/bs.js
  25. +1 −0 src/locale/ca.js
  26. +1 −0 src/locale/cs.js
  27. +1 −0 src/locale/cv.js
  28. +1 −0 src/locale/cy.js
  29. +1 −0 src/locale/da.js
  30. +1 −0 src/locale/de-at.js
  31. +1 −0 src/locale/de-ch.js
  32. +1 −0 src/locale/de.js
  33. +1 −0 src/locale/dv.js
  34. +1 −0 src/locale/el.js
  35. +1 −0 src/locale/en-SG.js
  36. +1 −0 src/locale/en-au.js
  37. +1 −0 src/locale/en-ca.js
  38. +2 −0 src/locale/en-gb.js
  39. +1 −0 src/locale/en-ie.js
  40. +1 −0 src/locale/en-il.js
  41. +1 −0 src/locale/en-nz.js
  42. +1 −0 src/locale/eo.js
  43. +1 −0 src/locale/es-do.js
  44. +1 −0 src/locale/es-us.js
  45. +1 −0 src/locale/es.js
  46. +31 −19 src/locale/et.js
  47. +1 −0 src/locale/eu.js
  48. +1 −0 src/locale/fa.js
  49. +1 −0 src/locale/fi.js
  50. +1 −0 src/locale/fo.js
  51. +1 −0 src/locale/fr-ca.js
  52. +1 −0 src/locale/fr-ch.js
  53. +1 −0 src/locale/fr.js
  54. +1 −0 src/locale/fy.js
  55. +1 −0 src/locale/ga.js
  56. +1 −0 src/locale/gd.js
  57. +1 −0 src/locale/gl.js
  58. +1 −0 src/locale/gom-latn.js
  59. +1 −0 src/locale/gu.js
  60. +1 −0 src/locale/he.js
  61. +1 −0 src/locale/hi.js
  62. +1 −0 src/locale/hr.js
  63. +1 −0 src/locale/hu.js
  64. +1 −0 src/locale/hy-am.js
  65. +1 −0 src/locale/id.js
  66. +1 −0 src/locale/is.js
  67. +1 −0 src/locale/it-ch.js
  68. +1 −0 src/locale/it.js
  69. +1 −0 src/locale/ja.js
  70. +1 −0 src/locale/jv.js
  71. +1 −0 src/locale/ka.js
  72. +1 −0 src/locale/kk.js
  73. +1 −0 src/locale/km.js
  74. +1 −0 src/locale/kn.js
  75. +1 −0 src/locale/ko.js
  76. +1 −0 src/locale/ku.js
  77. +1 −0 src/locale/ky.js
  78. +1 −0 src/locale/lb.js
  79. +1 −0 src/locale/lo.js
  80. +1 −0 src/locale/lt.js
  81. +1 −0 src/locale/lv.js
  82. +1 −0 src/locale/me.js
  83. +1 −0 src/locale/mi.js
  84. +1 −0 src/locale/mk.js
  85. +1 −0 src/locale/ml.js
  86. +1 −0 src/locale/mn.js
  87. +1 −0 src/locale/mr.js
  88. +1 −0 src/locale/ms-my.js
  89. +1 −0 src/locale/ms.js
  90. +1 −0 src/locale/mt.js
  91. +1 −0 src/locale/my.js
  92. +1 −0 src/locale/nb.js
  93. +1 −0 src/locale/ne.js
  94. +1 −0 src/locale/nl-be.js
  95. +1 −0 src/locale/nl.js
  96. +1 −0 src/locale/nn.js
  97. +1 −0 src/locale/oc-lnc.js
  98. +1 −0 src/locale/pa-in.js
  99. +31 −8 src/locale/pl.js
  100. +1 −0 src/locale/pt-br.js
  101. +1 −0 src/locale/pt.js
  102. +1 −0 src/locale/ro.js
  103. +1 −0 src/locale/ru.js
  104. +1 −0 src/locale/sd.js
  105. +1 −0 src/locale/se.js
  106. +1 −0 src/locale/si.js
  107. +1 −0 src/locale/sk.js
  108. +1 −0 src/locale/sl.js
  109. +1 −0 src/locale/sq.js
  110. +1 −0 src/locale/sr-cyrl.js
  111. +1 −0 src/locale/sr.js
  112. +1 −0 src/locale/ss.js
  113. +1 −0 src/locale/sv.js
  114. +1 −0 src/locale/sw.js
  115. +1 −0 src/locale/ta.js
  116. +1 −0 src/locale/te.js
  117. +1 −0 src/locale/tet.js
  118. +1 −0 src/locale/tg.js
  119. +1 −0 src/locale/th.js
  120. +1 −0 src/locale/tl-ph.js
  121. +1 −0 src/locale/tlh.js
  122. +1 −0 src/locale/tr.js
  123. +1 −0 src/locale/tzl.js
  124. +1 −0 src/locale/tzm-latn.js
  125. +1 −0 src/locale/tzm.js
  126. +1 −0 src/locale/ug-cn.js
  127. +1 −0 src/locale/uk.js
  128. +1 −0 src/locale/ur.js
  129. +1 −0 src/locale/uz-latn.js
  130. +1 −0 src/locale/uz.js
  131. +1 −0 src/locale/vi.js
  132. +1 −0 src/locale/x-pseudo.js
  133. +1 −0 src/locale/yo.js
  134. +2 −0 src/locale/zh-cn.js
  135. +1 −0 src/locale/zh-hk.js
  136. +1 −0 src/locale/zh-tw.js
  137. +19 −3 src/plugin/localeData/index.js
  138. +17 −8 src/plugin/weekOfYear/index.js
  139. +38 −0 test/locale/et.test.js
  140. +2 −0 test/locale/keys.test.js
  141. +47 −0 test/locale/pl.test.js
  142. +25 −10 test/plugin/localeData.test.js
  143. +16 −5 test/plugin/weekOfYear.test.js
  144. +4 −0 test/plugin/weekday.test.js
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [1.8.20](https://github.com/iamkun/dayjs/compare/v1.8.19...v1.8.20) (2020-02-04)


### Bug Fixes

* Add Bislama Locale (bi) ([#780](https://github.com/iamkun/dayjs/issues/780)) ([9ac6ab4](https://github.com/iamkun/dayjs/commit/9ac6ab481bc883dd4ecc02caab12c8b2fc218a42))
* Fix weekOfYear plugin to support yearStart locale for better week number result ([#769](https://github.com/iamkun/dayjs/issues/769)) ([f00db36](https://github.com/iamkun/dayjs/commit/f00db36e70bc7beaca1abadeb30a9b1fbb3261ee))
* Update et (Estonian) locale relativeTime ([#790](https://github.com/iamkun/dayjs/issues/790)) ([d8e0f45](https://github.com/iamkun/dayjs/commit/d8e0f45f6cd2d5e5704b9797929227454c92d1a5))
* Update LocaleData plugin to support dayjs.localeData().weekdays() API ([287fed6](https://github.com/iamkun/dayjs/commit/287fed6db9eb4fd979b4861aca4dacbd32422533)), closes [#779](https://github.com/iamkun/dayjs/issues/779)
* Update LocaleData plugin to support dayjs.months dayjs.weekdays API ([144c2ae](https://github.com/iamkun/dayjs/commit/144c2ae6e15fbf89e3acd7c8cb9e237c5f6e1348)), closes [#779](https://github.com/iamkun/dayjs/issues/779)
* Update pl locale fusional config ([d372475](https://github.com/iamkun/dayjs/commit/d3724758bb27d5b17587b995ba14e7e80dcd1151))

## [1.8.19](https://github.com/iamkun/dayjs/compare/v1.8.18...v1.8.19) (2020-01-06)


1 change: 1 addition & 0 deletions docs/en/I18n.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions docs/es-es/I18n.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/ja/I18n.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/ko/I18n.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/pt-br/I18n.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/zh-cn/I18n.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/locale/af.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Afrikaans [af]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-dz.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Algeria) [ar-dz]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-kw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Kuwait) [ar-kw]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-ly.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Lybia) [ar-ly]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-ma.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Morocco) [ar-ma]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-sa.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Saudi Arabia) [ar-sa]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar-tn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic (Tunisia) [ar-tn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Arabic [ar]
import dayjs from 'dayjs'

const months = 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_')
1 change: 1 addition & 0 deletions src/locale/az.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Azerbaijani [az]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/be.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Belarusian [be]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/bg.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Bulgarian [bg]
import dayjs from 'dayjs'

const locale = {
39 changes: 39 additions & 0 deletions src/locale/bi.js
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/locale/bm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Bambara [bm]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/bn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Bengali [bn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/bo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tibetan [bo]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/br.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Breton [br]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/bs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Bosnian [bs]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ca.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Catalan [ca]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/cs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Czech [cs]
import dayjs from 'dayjs'

function plural(n) {
1 change: 1 addition & 0 deletions src/locale/cv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Chuvash [cv]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Welsh [cy]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/da.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Danish [da]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/de-at.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// German (Austria) [de-at]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/de-ch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// German (Switzerland) [de-ch]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/de.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// German [de]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/dv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Maldivian [dv]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/el.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Greek [el]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/en-SG.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (Singapore) [en-sg]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/en-au.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (Australia) [en-au]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/en-ca.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (Canada) [en-ca]
import dayjs from 'dayjs'

const locale = {
2 changes: 2 additions & 0 deletions src/locale/en-gb.js
Original file line number Diff line number Diff line change
@@ -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',
1 change: 1 addition & 0 deletions src/locale/en-ie.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (Ireland) [en-ie]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/en-il.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (Israel) [en-il]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/en-nz.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// English (New Zealand) [en-nz]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/eo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Esperanto [eo]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/es-do.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Spanish (Dominican Republic) [es-do]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/es-us.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Spanish (United States) [es-us]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/es.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Spanish [es]
import dayjs from 'dayjs'

const locale = {
50 changes: 31 additions & 19 deletions src/locale/et.js
Original file line number Diff line number Diff line change
@@ -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',
1 change: 1 addition & 0 deletions src/locale/eu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Basque [eu]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fa.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Persian [fa]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Finnish [fi]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Faroese [fo]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fr-ca.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// French (Canada) [fr-ca]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fr-ch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// French (Switzerland) [fr-ch]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// French [fr]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/fy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Frisian [fy]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ga.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Irish or Irish Gaelic [ga]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/gd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Scottish Gaelic [gd]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/gl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Galician [gl]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/gom-latn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Konkani Latin script [gom-latn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/gu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Gujarati [gu]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/he.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Hebrew [he]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/hi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Hindi [hi]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/hr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Croatian [hr]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/hu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Hungarian [hu]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/hy-am.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Armenian [hy-am]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/id.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Indonesian [id]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/is.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Icelandic [is]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/it-ch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Italian (Switzerland) [it-ch]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/it.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Italian [it]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ja.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Japanese [ja]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/jv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Javanese [jv]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ka.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Georgian [ka]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/kk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Kazakh [kk]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/km.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Cambodian [km]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/kn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Kannada [kn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ko.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Korean [ko]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ku.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Kurdish [ku]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ky.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Kyrgyz [ky]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/lb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Luxembourgish [lb]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/lo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Lao [lo]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/lt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Lithuanian [lt]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/lv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Latvian [lv]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/me.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Montenegrin [me]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/mi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Maori [mi]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/mk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Macedonian [mk]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ml.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Malayalam [ml]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/mn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Mongolian [mn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/mr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Marathi [mr]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ms-my.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Malay [ms-my]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Malay [ms]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/mt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Maltese (Malta) [mt]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/my.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Burmese [my]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/nb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Norwegian Bokmål [nb]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ne.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Nepalese [ne]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/nl-be.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Dutch (Belgium) [nl-be]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/nl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Dutch [nl]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/nn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Nynorsk [nn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/oc-lnc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Occitan, lengadocian dialecte [oc-lnc]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/pa-in.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Punjabi (India) [pa-in]
import dayjs from 'dayjs'

const locale = {
39 changes: 31 additions & 8 deletions src/locale/pl.js
Original file line number Diff line number Diff line change
@@ -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',
1 change: 1 addition & 0 deletions src/locale/pt-br.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Portuguese (Brazil) [pt-br]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/pt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Portuguese [pt]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ro.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Romanian [ro]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ru.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Russian [ru]
import dayjs from 'dayjs'

const monthFormat = 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
1 change: 1 addition & 0 deletions src/locale/sd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Sindhi [sd]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/se.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Northern Sami [se]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/si.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Sinhalese [si]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Slovak [sk]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Slovenian [sl]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sq.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Albanian [sq]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sr-cyrl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Serbian Cyrillic [sr-cyrl]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Serbian [sr]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// siSwati [ss]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Swedish [sv]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/sw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Swahili [sw]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tamil [ta]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/te.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Telugu [te]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tetun Dili (East Timor) [tet]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tg.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tajik [tg]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/th.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Thai [th]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tl-ph.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tagalog (Philippines) [tl-ph]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tlh.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Klingon [tlh]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tr.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Turkish [tr]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tzl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Talossan [tzl]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tzm-latn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Central Atlas Tamazight Latin [tzm-latn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/tzm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Central Atlas Tamazight [tzm]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/ug-cn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Uyghur (China) [ug-cn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/uk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Ukrainian [uk]
import dayjs from 'dayjs'

function plural(word, num) {
1 change: 1 addition & 0 deletions src/locale/ur.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Urdu [ur]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/uz-latn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Uzbek Latin [uz-latn]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/uz.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Uzbek [uz]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/vi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Vietnamese [vi]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/x-pseudo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Pseudo [x-pseudo]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/yo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Yoruba Nigeria [yo]
import dayjs from 'dayjs'

const locale = {
2 changes: 2 additions & 0 deletions src/locale/zh-cn.js
Original file line number Diff line number Diff line change
@@ -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',
1 change: 1 addition & 0 deletions src/locale/zh-hk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Chinese (Hong Kong) [zh-hk]
import dayjs from 'dayjs'

const locale = {
1 change: 1 addition & 0 deletions src/locale/zh-tw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Chinese (Taiwan) [zh-tw]
import dayjs from 'dayjs'

const locale = {
22 changes: 19 additions & 3 deletions src/plugin/localeData/index.js
Original file line number Diff line number Diff line change
@@ -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)
}
25 changes: 17 additions & 8 deletions src/plugin/weekOfYear/index.js
Original file line number Diff line number Diff line change
@@ -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) {
38 changes: 38 additions & 0 deletions test/locale/et.test.js
Original file line number Diff line number Diff line change
@@ -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))
})
})
2 changes: 2 additions & 0 deletions test/locale/keys.test.js
Original file line number Diff line number Diff line change
@@ -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)) {
47 changes: 47 additions & 0 deletions test/locale/pl.test.js
Original file line number Diff line number Diff line change
@@ -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))
})
})
35 changes: 25 additions & 10 deletions test/plugin/localeData.test.js
Original file line number Diff line number Diff line change
@@ -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())
})
})
21 changes: 16 additions & 5 deletions test/plugin/weekOfYear.test.js
Original file line number Diff line number Diff line change
@@ -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', () => {
4 changes: 4 additions & 0 deletions test/plugin/weekday.test.js
Original file line number Diff line number Diff line change
@@ -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', () => {