From 317fd3e6893c3f1cd60165c207bf88d4fd2e33bf Mon Sep 17 00:00:00 2001 From: HoSung Lim Date: Mon, 25 Mar 2019 12:13:58 +0900 Subject: [PATCH 01/17] fix: Update ko locale weekdaysShort (#543) --- src/locale/ko.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locale/ko.js b/src/locale/ko.js index c5d3860a9..0f89f59fc 100644 --- a/src/locale/ko.js +++ b/src/locale/ko.js @@ -3,6 +3,7 @@ import dayjs from 'dayjs' const locale = { name: 'ko', weekdays: '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'), + weekdaysShort: '일_월_화_수_목_금_토'.split('_'), months: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'), ordinal: n => n, formats: { From f75a125cf1ce2d131d434276d0db667f3a72401b Mon Sep 17 00:00:00 2001 From: xxyuk <42378428+xxyuk@users.noreply.github.com> Date: Thu, 28 Mar 2019 10:39:30 +0800 Subject: [PATCH 02/17] fix: Add 79 locales (#541) --- src/locale/af.js | 17 +++++++++++++++++ src/locale/ar-dz.js | 16 ++++++++++++++++ src/locale/ar-kw.js | 16 ++++++++++++++++ src/locale/ar-ly.js | 17 +++++++++++++++++ src/locale/ar-ma.js | 17 +++++++++++++++++ src/locale/ar-sa.js | 16 ++++++++++++++++ src/locale/ar-tn.js | 17 +++++++++++++++++ src/locale/be.js | 17 +++++++++++++++++ src/locale/bm.js | 17 +++++++++++++++++ src/locale/bn.js | 16 ++++++++++++++++ src/locale/bo.js | 16 ++++++++++++++++ src/locale/br.js | 17 +++++++++++++++++ src/locale/bs.js | 17 +++++++++++++++++ src/locale/cv.js | 17 +++++++++++++++++ src/locale/cy.js | 17 +++++++++++++++++ src/locale/de-ch.js | 17 +++++++++++++++++ src/locale/dv.js | 17 +++++++++++++++++ src/locale/en-SG.js | 17 +++++++++++++++++ src/locale/en-au.js | 17 +++++++++++++++++ src/locale/en-ca.js | 16 ++++++++++++++++ src/locale/en-ie.js | 17 +++++++++++++++++ src/locale/en-il.js | 16 ++++++++++++++++ src/locale/en-nz.js | 17 +++++++++++++++++ src/locale/eo.js | 17 +++++++++++++++++ src/locale/eu.js | 17 +++++++++++++++++ src/locale/fo.js | 17 +++++++++++++++++ src/locale/fr-ca.js | 16 ++++++++++++++++ src/locale/fr-ch.js | 17 +++++++++++++++++ src/locale/fy.js | 16 ++++++++++++++++ src/locale/ga.js | 17 +++++++++++++++++ src/locale/gd.js | 17 +++++++++++++++++ src/locale/gl.js | 17 +++++++++++++++++ src/locale/gom-latn.js | 17 +++++++++++++++++ src/locale/gu.js | 16 ++++++++++++++++ src/locale/hi.js | 16 ++++++++++++++++ src/locale/hy-am.js | 17 +++++++++++++++++ src/locale/is.js | 17 +++++++++++++++++ src/locale/it-ch.js | 17 +++++++++++++++++ src/locale/jv.js | 17 +++++++++++++++++ src/locale/km.js | 17 +++++++++++++++++ src/locale/kn.js | 16 ++++++++++++++++ src/locale/ku.js | 17 +++++++++++++++++ src/locale/ky.js | 17 +++++++++++++++++ src/locale/lb.js | 17 +++++++++++++++++ src/locale/lo.js | 16 ++++++++++++++++ src/locale/lv.js | 17 +++++++++++++++++ src/locale/me.js | 17 +++++++++++++++++ src/locale/mi.js | 17 +++++++++++++++++ src/locale/mk.js | 17 +++++++++++++++++ src/locale/ml.js | 16 ++++++++++++++++ src/locale/mn.js | 16 ++++++++++++++++ src/locale/mr.js | 16 ++++++++++++++++ src/locale/ms-my.js | 17 +++++++++++++++++ src/locale/mt.js | 17 +++++++++++++++++ src/locale/my.js | 17 +++++++++++++++++ src/locale/nl-be.js | 16 ++++++++++++++++ src/locale/pa-in.js | 16 ++++++++++++++++ src/locale/sd.js | 17 +++++++++++++++++ src/locale/se.js | 17 +++++++++++++++++ src/locale/si.js | 16 ++++++++++++++++ src/locale/sl.js | 17 +++++++++++++++++ src/locale/sq.js | 17 +++++++++++++++++ src/locale/ss.js | 17 +++++++++++++++++ src/locale/ta.js | 16 ++++++++++++++++ src/locale/te.js | 16 ++++++++++++++++ src/locale/tet.js | 17 +++++++++++++++++ src/locale/tg.js | 17 +++++++++++++++++ src/locale/tl-ph.js | 17 +++++++++++++++++ src/locale/tlh.js | 17 +++++++++++++++++ src/locale/tzl.js | 17 +++++++++++++++++ src/locale/tzm-latn.js | 17 +++++++++++++++++ src/locale/tzm.js | 17 +++++++++++++++++ src/locale/ug-cn.js | 17 +++++++++++++++++ src/locale/ur.js | 17 +++++++++++++++++ src/locale/uz-latn.js | 17 +++++++++++++++++ src/locale/uz.js | 17 +++++++++++++++++ src/locale/vi.js | 17 +++++++++++++++++ src/locale/x-pseudo.js | 17 +++++++++++++++++ src/locale/yo.js | 17 +++++++++++++++++ 79 files changed, 1322 insertions(+) create mode 100644 src/locale/af.js create mode 100644 src/locale/ar-dz.js create mode 100644 src/locale/ar-kw.js create mode 100644 src/locale/ar-ly.js create mode 100644 src/locale/ar-ma.js create mode 100644 src/locale/ar-sa.js create mode 100644 src/locale/ar-tn.js create mode 100644 src/locale/be.js create mode 100644 src/locale/bm.js create mode 100644 src/locale/bn.js create mode 100644 src/locale/bo.js create mode 100644 src/locale/br.js create mode 100644 src/locale/bs.js create mode 100644 src/locale/cv.js create mode 100644 src/locale/cy.js create mode 100644 src/locale/de-ch.js create mode 100644 src/locale/dv.js create mode 100644 src/locale/en-SG.js create mode 100644 src/locale/en-au.js create mode 100644 src/locale/en-ca.js create mode 100644 src/locale/en-ie.js create mode 100644 src/locale/en-il.js create mode 100644 src/locale/en-nz.js create mode 100644 src/locale/eo.js create mode 100644 src/locale/eu.js create mode 100644 src/locale/fo.js create mode 100644 src/locale/fr-ca.js create mode 100644 src/locale/fr-ch.js create mode 100644 src/locale/fy.js create mode 100644 src/locale/ga.js create mode 100644 src/locale/gd.js create mode 100644 src/locale/gl.js create mode 100644 src/locale/gom-latn.js create mode 100644 src/locale/gu.js create mode 100644 src/locale/hi.js create mode 100644 src/locale/hy-am.js create mode 100644 src/locale/is.js create mode 100644 src/locale/it-ch.js create mode 100644 src/locale/jv.js create mode 100644 src/locale/km.js create mode 100644 src/locale/kn.js create mode 100644 src/locale/ku.js create mode 100644 src/locale/ky.js create mode 100644 src/locale/lb.js create mode 100644 src/locale/lo.js create mode 100644 src/locale/lv.js create mode 100644 src/locale/me.js create mode 100644 src/locale/mi.js create mode 100644 src/locale/mk.js create mode 100644 src/locale/ml.js create mode 100644 src/locale/mn.js create mode 100644 src/locale/mr.js create mode 100644 src/locale/ms-my.js create mode 100644 src/locale/mt.js create mode 100644 src/locale/my.js create mode 100644 src/locale/nl-be.js create mode 100644 src/locale/pa-in.js create mode 100644 src/locale/sd.js create mode 100644 src/locale/se.js create mode 100644 src/locale/si.js create mode 100644 src/locale/sl.js create mode 100644 src/locale/sq.js create mode 100644 src/locale/ss.js create mode 100644 src/locale/ta.js create mode 100644 src/locale/te.js create mode 100644 src/locale/tet.js create mode 100644 src/locale/tg.js create mode 100644 src/locale/tl-ph.js create mode 100644 src/locale/tlh.js create mode 100644 src/locale/tzl.js create mode 100644 src/locale/tzm-latn.js create mode 100644 src/locale/tzm.js create mode 100644 src/locale/ug-cn.js create mode 100644 src/locale/ur.js create mode 100644 src/locale/uz-latn.js create mode 100644 src/locale/uz.js create mode 100644 src/locale/vi.js create mode 100644 src/locale/x-pseudo.js create mode 100644 src/locale/yo.js diff --git a/src/locale/af.js b/src/locale/af.js new file mode 100644 index 000000000..e1bce5ace --- /dev/null +++ b/src/locale/af.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'af', + weekdays: 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'), + months: 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'), + weekStart: 1, + weekdaysShort: 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'), + weekdaysMin: 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-dz.js b/src/locale/ar-dz.js new file mode 100644 index 000000000..651454eb0 --- /dev/null +++ b/src/locale/ar-dz.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-dz', + weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysShort: 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysMin: 'أح_إث_ثلا_أر_خم_جم_سب'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-kw.js b/src/locale/ar-kw.js new file mode 100644 index 000000000..106703090 --- /dev/null +++ b/src/locale/ar-kw.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-kw', + weekdays: 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), + weekdaysShort: 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), + weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-ly.js b/src/locale/ar-ly.js new file mode 100644 index 000000000..932362927 --- /dev/null +++ b/src/locale/ar-ly.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-ly', + weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekStart: 6, + weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-ma.js b/src/locale/ar-ma.js new file mode 100644 index 000000000..819b06be9 --- /dev/null +++ b/src/locale/ar-ma.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-ma', + weekdays: 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), + weekStart: 6, + weekdaysShort: 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'), + weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-sa.js b/src/locale/ar-sa.js new file mode 100644 index 000000000..1801f27c1 --- /dev/null +++ b/src/locale/ar-sa.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-sa', + weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ar-tn.js b/src/locale/ar-tn.js new file mode 100644 index 000000000..b84b8130f --- /dev/null +++ b/src/locale/ar-tn.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ar-tn', + weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), + months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekStart: 1, + weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), + monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'), + weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/be.js b/src/locale/be.js new file mode 100644 index 000000000..6bc5dec93 --- /dev/null +++ b/src/locale/be.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'be', + weekdays: 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_'), + months: 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_'), + weekStart: 1, + weekdaysShort: 'нд_пн_ат_ср_чц_пт_сб'.split('_'), + monthsShort: 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'), + weekdaysMin: 'нд_пн_ат_ср_чц_пт_сб'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/bm.js b/src/locale/bm.js new file mode 100644 index 000000000..911775ee1 --- /dev/null +++ b/src/locale/bm.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'bm', + weekdays: 'Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri'.split('_'), + months: 'Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo'.split('_'), + weekStart: 1, + weekdaysShort: 'Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib'.split('_'), + monthsShort: 'Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des'.split('_'), + weekdaysMin: 'Ka_Nt_Ta_Ar_Al_Ju_Si'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/bn.js b/src/locale/bn.js new file mode 100644 index 000000000..1675bbf47 --- /dev/null +++ b/src/locale/bn.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'bn', + weekdays: 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'), + months: 'জানুয়ারী_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), + weekdaysShort: 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'), + monthsShort: 'জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), + weekdaysMin: 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/bo.js b/src/locale/bo.js new file mode 100644 index 000000000..738222572 --- /dev/null +++ b/src/locale/bo.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'bo', + weekdays: 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'), + months: 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), + weekdaysShort: 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'), + monthsShort: 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), + weekdaysMin: 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/br.js b/src/locale/br.js new file mode 100644 index 000000000..7c935ac7c --- /dev/null +++ b/src/locale/br.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'br', + weekdays: "Sul_Lun_Meurzh_Merc'her_Yaou_Gwener_Sadorn".split('_'), + months: "Genver_C'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split('_'), + weekStart: 1, + weekdaysShort: 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'), + monthsShort: "Gen_C'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split('_'), + weekdaysMin: 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/bs.js b/src/locale/bs.js new file mode 100644 index 000000000..052a2a39d --- /dev/null +++ b/src/locale/bs.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'bs', + weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'), + months: 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'), + weekStart: 1, + weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'), + monthsShort: 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'), + weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/cv.js b/src/locale/cv.js new file mode 100644 index 000000000..1bddc8457 --- /dev/null +++ b/src/locale/cv.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'cv', + weekdays: 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'), + months: 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'), + weekStart: 1, + weekdaysShort: 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'), + monthsShort: 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'), + weekdaysMin: 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/cy.js b/src/locale/cy.js new file mode 100644 index 000000000..62e032fd8 --- /dev/null +++ b/src/locale/cy.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'cy', + weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'), + months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'), + weekStart: 1, + weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'), + monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'), + weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/de-ch.js b/src/locale/de-ch.js new file mode 100644 index 000000000..49e5ac110 --- /dev/null +++ b/src/locale/de-ch.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'de-ch', + weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), + months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), + weekStart: 1, + weekdaysShort: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), + monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'), + weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/dv.js b/src/locale/dv.js new file mode 100644 index 000000000..590ff6cb4 --- /dev/null +++ b/src/locale/dv.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'dv', + weekdays: 'އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު'.split('_'), + months: 'ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު'.split('_'), + weekStart: 7, + weekdaysShort: 'އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު'.split('_'), + monthsShort: 'ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު'.split('_'), + weekdaysMin: 'އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-SG.js b/src/locale/en-SG.js new file mode 100644 index 000000000..11805d522 --- /dev/null +++ b/src/locale/en-SG.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-SG', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekStart: 1, + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-au.js b/src/locale/en-au.js new file mode 100644 index 000000000..4b35e771e --- /dev/null +++ b/src/locale/en-au.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-au', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekStart: 1, + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-ca.js b/src/locale/en-ca.js new file mode 100644 index 000000000..a14117202 --- /dev/null +++ b/src/locale/en-ca.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-ca', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-ie.js b/src/locale/en-ie.js new file mode 100644 index 000000000..ae1f9815f --- /dev/null +++ b/src/locale/en-ie.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-ie', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekStart: 1, + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-il.js b/src/locale/en-il.js new file mode 100644 index 000000000..a1e1bfb6b --- /dev/null +++ b/src/locale/en-il.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-il', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/en-nz.js b/src/locale/en-nz.js new file mode 100644 index 000000000..66f3d4c42 --- /dev/null +++ b/src/locale/en-nz.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'en-nz', + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + weekStart: 1, + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/eo.js b/src/locale/eo.js new file mode 100644 index 000000000..bc6144654 --- /dev/null +++ b/src/locale/eo.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'eo', + weekdays: 'dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato'.split('_'), + months: 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'), + weekStart: 1, + weekdaysShort: 'dim_lun_mard_merk_ĵaŭ_ven_sab'.split('_'), + monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'), + weekdaysMin: 'di_lu_ma_me_ĵa_ve_sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/eu.js b/src/locale/eu.js new file mode 100644 index 000000000..5106811c7 --- /dev/null +++ b/src/locale/eu.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'eu', + weekdays: 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'), + months: 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'), + weekStart: 1, + weekdaysShort: 'ig._al._ar._az._og._ol._lr.'.split('_'), + monthsShort: 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'), + weekdaysMin: 'ig_al_ar_az_og_ol_lr'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/fo.js b/src/locale/fo.js new file mode 100644 index 000000000..a8d3b6ff8 --- /dev/null +++ b/src/locale/fo.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'fo', + weekdays: 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'), + months: 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'), + weekStart: 1, + weekdaysShort: 'sun_mán_týs_mik_hós_frí_ley'.split('_'), + monthsShort: 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'), + weekdaysMin: 'su_má_tý_mi_hó_fr_le'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/fr-ca.js b/src/locale/fr-ca.js new file mode 100644 index 000000000..4bf3b01ff --- /dev/null +++ b/src/locale/fr-ca.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'fr-ca', + weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), + months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), + weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), + monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), + weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/fr-ch.js b/src/locale/fr-ch.js new file mode 100644 index 000000000..4f8c42a1c --- /dev/null +++ b/src/locale/fr-ch.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'fr-ch', + weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), + months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), + weekStart: 1, + weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), + monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), + weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/fy.js b/src/locale/fy.js new file mode 100644 index 000000000..309fd0c45 --- /dev/null +++ b/src/locale/fy.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'fy', + weekdays: 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'), + months: 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'), + weekStart: 1, + weekdaysShort: 'si._mo._ti._wo._to._fr._so.'.split('_'), + weekdaysMin: 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ga.js b/src/locale/ga.js new file mode 100644 index 000000000..dd7271b5f --- /dev/null +++ b/src/locale/ga.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ga', + weekdays: 'Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Satharn'.split('_'), + months: 'Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Méitheamh_Iúil_Lúnasa_Meán Fómhair_Deaireadh Fómhair_Samhain_Nollaig'.split('_'), + weekStart: 1, + weekdaysShort: 'Dom_Lua_Mái_Céa_Déa_hAo_Sat'.split('_'), + monthsShort: 'Eaná_Feab_Márt_Aibr_Beal_Méit_Iúil_Lúna_Meán_Deai_Samh_Noll'.split('_'), + weekdaysMin: 'Do_Lu_Má_Ce_Dé_hA_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/gd.js b/src/locale/gd.js new file mode 100644 index 000000000..89724db93 --- /dev/null +++ b/src/locale/gd.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'gd', + weekdays: 'Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne'.split('_'), + months: 'Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd'.split('_'), + weekStart: 1, + weekdaysShort: 'Did_Dil_Dim_Dic_Dia_Dih_Dis'.split('_'), + monthsShort: 'Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh'.split('_'), + weekdaysMin: 'Dò_Lu_Mà_Ci_Ar_Ha_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/gl.js b/src/locale/gl.js new file mode 100644 index 000000000..d1619d36b --- /dev/null +++ b/src/locale/gl.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'gl', + weekdays: 'domingo_luns_martes_mércores_xoves_venres_sábado'.split('_'), + months: 'xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro'.split('_'), + weekStart: 1, + weekdaysShort: 'dom._lun._mar._mér._xov._ven._sáb.'.split('_'), + monthsShort: 'xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.'.split('_'), + weekdaysMin: 'do_lu_ma_mé_xo_ve_sá'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/gom-latn.js b/src/locale/gom-latn.js new file mode 100644 index 000000000..772004093 --- /dev/null +++ b/src/locale/gom-latn.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'gom-latn', + weekdays: "Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split('_'), + months: 'Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr'.split('_'), + weekStart: 1, + weekdaysShort: 'Ait._Som._Mon._Bud._Bre._Suk._Son.'.split('_'), + monthsShort: 'Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.'.split('_'), + weekdaysMin: 'Ai_Sm_Mo_Bu_Br_Su_Sn'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/gu.js b/src/locale/gu.js new file mode 100644 index 000000000..37cc58007 --- /dev/null +++ b/src/locale/gu.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'gu', + weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split('_'), + months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split('_'), + weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'), + monthsShort: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split('_'), + weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/hi.js b/src/locale/hi.js new file mode 100644 index 000000000..f8e181a49 --- /dev/null +++ b/src/locale/hi.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'hi', + weekdays: 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), + months: 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'), + weekdaysShort: 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'), + monthsShort: 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'), + weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/hy-am.js b/src/locale/hy-am.js new file mode 100644 index 000000000..aeaf6770c --- /dev/null +++ b/src/locale/hy-am.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'hy-am', + weekdays: 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_'), + months: 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_'), + weekStart: 1, + weekdaysShort: 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'), + monthsShort: 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'), + weekdaysMin: 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/is.js b/src/locale/is.js new file mode 100644 index 000000000..9ae4c5402 --- /dev/null +++ b/src/locale/is.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'is', + weekdays: 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'), + months: 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'), + weekStart: 1, + weekdaysShort: 'sun_mán_þri_mið_fim_fös_lau'.split('_'), + monthsShort: 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'), + weekdaysMin: 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/it-ch.js b/src/locale/it-ch.js new file mode 100644 index 000000000..8e164779c --- /dev/null +++ b/src/locale/it-ch.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'it-ch', + weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'), + months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'), + weekStart: 1, + weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'), + monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'), + weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/jv.js b/src/locale/jv.js new file mode 100644 index 000000000..589df04d8 --- /dev/null +++ b/src/locale/jv.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'jv', + weekdays: 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'), + months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'), + weekStart: 1, + weekdaysShort: 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'), + weekdaysMin: 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/km.js b/src/locale/km.js new file mode 100644 index 000000000..abee86d7a --- /dev/null +++ b/src/locale/km.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'km', + weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'), + months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'), + weekStart: 1, + weekdaysShort: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'), + monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'), + weekdaysMin: 'អា_ច_អ_ព_ព្រ_សុ_ស'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/kn.js b/src/locale/kn.js new file mode 100644 index 000000000..d8da1f9a4 --- /dev/null +++ b/src/locale/kn.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'kn', + weekdays: 'ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ'.split('_'), + months: 'ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್'.split('_'), + weekdaysShort: 'ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ'.split('_'), + monthsShort: 'ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ'.split('_'), + weekdaysMin: 'ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ku.js b/src/locale/ku.js new file mode 100644 index 000000000..26678a100 --- /dev/null +++ b/src/locale/ku.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ku', + weekdays: 'یه‌كشه‌ممه‌_دووشه‌ممه‌_سێشه‌ممه‌_چوارشه‌ممه‌_پێنجشه‌ممه‌_هه‌ینی_شه‌ممه‌'.split('_'), + months: 'کانونی دووەم_شوبات_ئازار_نیسان_ئایار_حوزەیران_تەمموز_ئاب_ئەیلوول_تشرینی یەكەم_تشرینی دووەم_كانونی یەکەم'.split('_'), + weekStart: 6, + weekdaysShort: 'یه‌كشه‌م_دووشه‌م_سێشه‌م_چوارشه‌م_پێنجشه‌م_هه‌ینی_شه‌ممه‌'.split('_'), + monthsShort: 'کانونی دووەم_شوبات_ئازار_نیسان_ئایار_حوزەیران_تەمموز_ئاب_ئەیلوول_تشرینی یەكەم_تشرینی دووەم_كانونی یەکەم'.split('_'), + weekdaysMin: 'ی_د_س_چ_پ_ه_ش'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ky.js b/src/locale/ky.js new file mode 100644 index 000000000..2119777b4 --- /dev/null +++ b/src/locale/ky.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ky', + weekdays: 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'), + months: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'), + weekStart: 1, + weekdaysShort: 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'), + monthsShort: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'), + weekdaysMin: 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/lb.js b/src/locale/lb.js new file mode 100644 index 000000000..173b45929 --- /dev/null +++ b/src/locale/lb.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'lb', + weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'), + months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), + weekStart: 1, + weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'), + monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'), + weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/lo.js b/src/locale/lo.js new file mode 100644 index 000000000..6b654aa20 --- /dev/null +++ b/src/locale/lo.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'lo', + weekdays: 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'), + months: 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'), + weekdaysShort: 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'), + monthsShort: 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'), + weekdaysMin: 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/lv.js b/src/locale/lv.js new file mode 100644 index 000000000..e9cbe952b --- /dev/null +++ b/src/locale/lv.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'lv', + weekdays: 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'), + months: 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'), + weekStart: 1, + weekdaysShort: 'Sv_P_O_T_C_Pk_S'.split('_'), + monthsShort: 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'), + weekdaysMin: 'Sv_P_O_T_C_Pk_S'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/me.js b/src/locale/me.js new file mode 100644 index 000000000..936bf79d0 --- /dev/null +++ b/src/locale/me.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'me', + weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'), + months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'), + weekStart: 1, + weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'), + monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'), + weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/mi.js b/src/locale/mi.js new file mode 100644 index 000000000..04e86c848 --- /dev/null +++ b/src/locale/mi.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'mi', + weekdays: 'Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei'.split('_'), + months: 'Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea'.split('_'), + weekStart: 1, + weekdaysShort: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'), + monthsShort: 'Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki'.split('_'), + weekdaysMin: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/mk.js b/src/locale/mk.js new file mode 100644 index 000000000..0fc8636c2 --- /dev/null +++ b/src/locale/mk.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'mk', + weekdays: 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'), + months: 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'), + weekStart: 1, + weekdaysShort: 'нед_пон_вто_сре_чет_пет_саб'.split('_'), + monthsShort: 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'), + weekdaysMin: 'нe_пo_вт_ср_че_пе_сa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ml.js b/src/locale/ml.js new file mode 100644 index 000000000..813b49f0a --- /dev/null +++ b/src/locale/ml.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ml', + weekdays: 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'), + months: 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'), + weekdaysShort: 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'), + monthsShort: 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'), + weekdaysMin: 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/mn.js b/src/locale/mn.js new file mode 100644 index 000000000..c38835906 --- /dev/null +++ b/src/locale/mn.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'mn', + weekdays: 'Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба'.split('_'), + months: 'Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар'.split('_'), + weekdaysShort: 'Ням_Дав_Мяг_Лха_Пүр_Баа_Бям'.split('_'), + monthsShort: '1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар'.split('_'), + weekdaysMin: 'Ня_Да_Мя_Лх_Пү_Ба_Бя'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/mr.js b/src/locale/mr.js new file mode 100644 index 000000000..350136f31 --- /dev/null +++ b/src/locale/mr.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'mr', + weekdays: 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), + months: 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'), + weekdaysShort: 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'), + monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'), + weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ms-my.js b/src/locale/ms-my.js new file mode 100644 index 000000000..5e448de89 --- /dev/null +++ b/src/locale/ms-my.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ms-my', + weekdays: 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'), + months: 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'), + weekStart: 1, + weekdaysShort: 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'), + monthsShort: 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'), + weekdaysMin: 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/mt.js b/src/locale/mt.js new file mode 100644 index 000000000..418de824d --- /dev/null +++ b/src/locale/mt.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'mt', + weekdays: 'Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt'.split('_'), + months: 'Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru'.split('_'), + weekStart: 1, + weekdaysShort: 'Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib'.split('_'), + monthsShort: 'Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ'.split('_'), + weekdaysMin: 'Ħa_Tn_Tl_Er_Ħa_Ġi_Si'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/my.js b/src/locale/my.js new file mode 100644 index 000000000..5478cf489 --- /dev/null +++ b/src/locale/my.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'my', + weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'), + months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'), + weekStart: 1, + weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'), + monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'), + weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/nl-be.js b/src/locale/nl-be.js new file mode 100644 index 000000000..64d545ca7 --- /dev/null +++ b/src/locale/nl-be.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'nl-be', + weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'), + months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), + weekStart: 1, + weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'), + weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/pa-in.js b/src/locale/pa-in.js new file mode 100644 index 000000000..d1774fa2e --- /dev/null +++ b/src/locale/pa-in.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'pa-in', + weekdays: 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'), + months: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'), + weekdaysShort: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'), + monthsShort: 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'), + weekdaysMin: 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/sd.js b/src/locale/sd.js new file mode 100644 index 000000000..000e816fd --- /dev/null +++ b/src/locale/sd.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'sd', + weekdays: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), + months: 'جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر'.split('_'), + weekStart: 1, + weekdaysShort: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), + monthsShort: 'جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر'.split('_'), + weekdaysMin: 'آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/se.js b/src/locale/se.js new file mode 100644 index 000000000..99db63f6c --- /dev/null +++ b/src/locale/se.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'se', + weekdays: 'sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat'.split('_'), + months: 'ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu'.split('_'), + weekStart: 1, + weekdaysShort: 'sotn_vuos_maŋ_gask_duor_bear_láv'.split('_'), + monthsShort: 'ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov'.split('_'), + weekdaysMin: 's_v_m_g_d_b_L'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/si.js b/src/locale/si.js new file mode 100644 index 000000000..192e9a107 --- /dev/null +++ b/src/locale/si.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'si', + weekdays: 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'), + months: 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'), + weekdaysShort: 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'), + monthsShort: 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'), + weekdaysMin: 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/sl.js b/src/locale/sl.js new file mode 100644 index 000000000..c68552ad6 --- /dev/null +++ b/src/locale/sl.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'sl', + weekdays: 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'), + months: 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'), + weekStart: 1, + weekdaysShort: 'ned._pon._tor._sre._čet._pet._sob.'.split('_'), + monthsShort: 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'), + weekdaysMin: 'ne_po_to_sr_če_pe_so'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/sq.js b/src/locale/sq.js new file mode 100644 index 000000000..ac8811927 --- /dev/null +++ b/src/locale/sq.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'sq', + weekdays: 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'), + months: 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'), + weekStart: 1, + weekdaysShort: 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'), + monthsShort: 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'), + weekdaysMin: 'D_H_Ma_Më_E_P_Sh'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ss.js b/src/locale/ss.js new file mode 100644 index 000000000..22a4ddacd --- /dev/null +++ b/src/locale/ss.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ss', + weekdays: 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'), + months: "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'), + weekStart: 1, + weekdaysShort: 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'), + monthsShort: 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'), + weekdaysMin: 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ta.js b/src/locale/ta.js new file mode 100644 index 000000000..1c15e5841 --- /dev/null +++ b/src/locale/ta.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ta', + weekdays: 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'), + months: 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'), + weekdaysShort: 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'), + monthsShort: 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'), + weekdaysMin: 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/te.js b/src/locale/te.js new file mode 100644 index 000000000..fd0bd6d98 --- /dev/null +++ b/src/locale/te.js @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'te', + weekdays: 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'), + months: 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'), + weekdaysShort: 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'), + monthsShort: 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'), + weekdaysMin: 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tet.js b/src/locale/tet.js new file mode 100644 index 000000000..aa152d6a3 --- /dev/null +++ b/src/locale/tet.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tet', + weekdays: 'Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu'.split('_'), + months: 'Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru'.split('_'), + weekStart: 1, + weekdaysShort: 'Dom_Seg_Ters_Kua_Kint_Sest_Sab'.split('_'), + monthsShort: 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'), + weekdaysMin: 'Do_Seg_Te_Ku_Ki_Ses_Sa'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tg.js b/src/locale/tg.js new file mode 100644 index 000000000..b2e0abbe5 --- /dev/null +++ b/src/locale/tg.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tg', + weekdays: 'якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе'.split('_'), + months: 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'), + weekStart: 1, + weekdaysShort: 'яшб_дшб_сшб_чшб_пшб_ҷум_шнб'.split('_'), + monthsShort: 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'), + weekdaysMin: 'яш_дш_сш_чш_пш_ҷм_шб'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tl-ph.js b/src/locale/tl-ph.js new file mode 100644 index 000000000..56611a7f1 --- /dev/null +++ b/src/locale/tl-ph.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tl-ph', + weekdays: 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'), + months: 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'), + weekStart: 1, + weekdaysShort: 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'), + monthsShort: 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'), + weekdaysMin: 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tlh.js b/src/locale/tlh.js new file mode 100644 index 000000000..69ff95c79 --- /dev/null +++ b/src/locale/tlh.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tlh', + weekdays: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), + months: 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'), + weekStart: 1, + weekdaysShort: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), + monthsShort: 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'), + weekdaysMin: 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tzl.js b/src/locale/tzl.js new file mode 100644 index 000000000..2c70fd676 --- /dev/null +++ b/src/locale/tzl.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tzl', + weekdays: 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'), + months: 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'), + weekStart: 1, + weekdaysShort: 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'), + monthsShort: 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'), + weekdaysMin: 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tzm-latn.js b/src/locale/tzm-latn.js new file mode 100644 index 000000000..df71adbad --- /dev/null +++ b/src/locale/tzm-latn.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tzm-latn', + weekdays: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), + months: 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'), + weekStart: 6, + weekdaysShort: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), + monthsShort: 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'), + weekdaysMin: 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/tzm.js b/src/locale/tzm.js new file mode 100644 index 000000000..4097e40a2 --- /dev/null +++ b/src/locale/tzm.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'tzm', + weekdays: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), + months: 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), + weekStart: 6, + weekdaysShort: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), + monthsShort: 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), + weekdaysMin: 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ug-cn.js b/src/locale/ug-cn.js new file mode 100644 index 000000000..fc864804a --- /dev/null +++ b/src/locale/ug-cn.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ug-cn', + weekdays: 'يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە'.split('_'), + months: 'يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر'.split('_'), + weekStart: 1, + weekdaysShort: 'يە_دۈ_سە_چا_پە_جۈ_شە'.split('_'), + monthsShort: 'يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر'.split('_'), + weekdaysMin: 'يە_دۈ_سە_چا_پە_جۈ_شە'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/ur.js b/src/locale/ur.js new file mode 100644 index 000000000..09e909f11 --- /dev/null +++ b/src/locale/ur.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'ur', + weekdays: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), + months: 'جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر'.split('_'), + weekStart: 1, + weekdaysShort: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), + monthsShort: 'جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر'.split('_'), + weekdaysMin: 'اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/uz-latn.js b/src/locale/uz-latn.js new file mode 100644 index 000000000..fbe2a9d43 --- /dev/null +++ b/src/locale/uz-latn.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'uz-latn', + weekdays: 'Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba'.split('_'), + months: 'Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr'.split('_'), + weekStart: 1, + weekdaysShort: 'Yak_Dush_Sesh_Chor_Pay_Jum_Shan'.split('_'), + monthsShort: 'Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek'.split('_'), + weekdaysMin: 'Ya_Du_Se_Cho_Pa_Ju_Sha'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/uz.js b/src/locale/uz.js new file mode 100644 index 000000000..7591d7f2d --- /dev/null +++ b/src/locale/uz.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'uz', + weekdays: 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'), + months: 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'), + weekStart: 1, + weekdaysShort: 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'), + monthsShort: 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'), + weekdaysMin: 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/vi.js b/src/locale/vi.js new file mode 100644 index 000000000..055e4593e --- /dev/null +++ b/src/locale/vi.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'vi', + weekdays: 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'), + months: 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'), + weekStart: 1, + weekdaysShort: 'CN_T2_T3_T4_T5_T6_T7'.split('_'), + monthsShort: 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'), + weekdaysMin: 'CN_T2_T3_T4_T5_T6_T7'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/x-pseudo.js b/src/locale/x-pseudo.js new file mode 100644 index 000000000..692c02570 --- /dev/null +++ b/src/locale/x-pseudo.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'x-pseudo', + weekdays: 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'), + months: 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'), + weekStart: 1, + weekdaysShort: 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'), + monthsShort: 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'), + weekdaysMin: 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + diff --git a/src/locale/yo.js b/src/locale/yo.js new file mode 100644 index 000000000..c9cf21ac4 --- /dev/null +++ b/src/locale/yo.js @@ -0,0 +1,17 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'yo', + weekdays: 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), + months: 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), + weekStart: 1, + weekdaysShort: 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), + monthsShort: 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), + weekdaysMin: 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), + ordinal: n => n +} + +dayjs.locale(locale, null, true) + +export default locale + From 2870a23d973e1b05c178393eb77682d377549f0e Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 28 Mar 2019 17:10:24 +0800 Subject: [PATCH 03/17] fix: Add plugin minMax to sopport .max .min --- src/plugin/minMax/index.js | 28 +++++++++++++++++++++++ test/plugin/minMax.test.js | 46 ++++++++++++++++++++++++++++++++++++++ types/plugin/minMax.d.ts | 11 +++++++++ 3 files changed, 85 insertions(+) create mode 100644 src/plugin/minMax/index.js create mode 100644 test/plugin/minMax.test.js create mode 100644 types/plugin/minMax.d.ts diff --git a/src/plugin/minMax/index.js b/src/plugin/minMax/index.js new file mode 100644 index 000000000..d96d0568f --- /dev/null +++ b/src/plugin/minMax/index.js @@ -0,0 +1,28 @@ +export default (o, c, d) => { + const sortBy = (method, dates) => { + if (!dates.length) { + return d() + } + if (dates.length === 1 && dates[0].length > 0) { + [dates] = dates + } + let result + [result] = dates + for (let i = 1; i < dates.length; i += 1) { + if (!dates[i].isValid() || dates[i][method](result)) { + result = dates[i] + } + } + return result + } + + d.max = function () { + const args = [].slice.call(arguments, 0) // eslint-disable-line prefer-rest-params + return sortBy('isAfter', args) + } + d.min = function () { + const args = [].slice.call(arguments, 0) // eslint-disable-line prefer-rest-params + return sortBy('isBefore', args) + } +} + diff --git a/test/plugin/minMax.test.js b/test/plugin/minMax.test.js new file mode 100644 index 000000000..7cc9db92d --- /dev/null +++ b/test/plugin/minMax.test.js @@ -0,0 +1,46 @@ +import MockDate from 'mockdate' +import dayjs from '../../src' +import minMax from '../../src/plugin/minMax' + +dayjs.extend(minMax) + +beforeEach(() => { + MockDate.set(new Date()) +}) + +afterEach(() => { + MockDate.reset() +}) + +const arg1 = dayjs('2019-01-01') +const arg2 = dayjs('2018-01-01') +const arg3 = dayjs('2017-01-01') +const arg4 = dayjs('Invalid Date') + +it('Return current time if no argument', () => { + expect(dayjs.max().format()) + .toBe(dayjs().format()) + expect(dayjs.min().format()) + .toBe(dayjs().format()) +}) + +it('Compare between arguments', () => { + expect(dayjs.max(arg1, arg2, arg3).format()) + .toBe(arg1.format()) + expect(dayjs.min(arg1, arg2, arg3).format()) + .toBe(arg3.format()) +}) + +it('Compare in array', () => { + expect(dayjs.max([arg1, arg2, arg3]).format()) + .toBe(arg1.format()) + expect(dayjs.min([arg1, arg2, arg3]).format()) + .toBe(arg3.format()) +}) + +it('If Invalid Date return Invalid Date', () => { + expect(dayjs.max(arg1, arg2, arg3, arg4).format()) + .toBe(arg4.format()) + expect(dayjs.min([arg1, arg2, arg3, arg4]).format()) + .toBe(arg4.format()) +}) diff --git a/types/plugin/minMax.d.ts b/types/plugin/minMax.d.ts new file mode 100644 index 000000000..1cca06ef2 --- /dev/null +++ b/types/plugin/minMax.d.ts @@ -0,0 +1,11 @@ +import { PluginFunc, ConfigType } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + export function max(dayjs: Dayjs[]): Dayjs + export function max(...dayjs: Dayjs[]): Dayjs + export function min(dayjs: Dayjs[]): Dayjs + export function min(...dayjs: Dayjs[]): Dayjs +} From 66e7ce6c890ccfa7a2dcb6e2641329f46cc3e692 Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 28 Mar 2019 17:45:25 +0800 Subject: [PATCH 04/17] docs: update minMax plugin docs --- docs/en/API-reference.md | 15 ++++++--------- docs/en/Plugin.md | 19 ++++++++++++++++--- docs/es-es/API-reference.md | 15 ++++++--------- docs/es-es/Plugin.md | 13 +++++++++++++ docs/ja/API-reference.md | 15 ++++++--------- docs/ja/Plugin.md | 13 +++++++++++++ docs/ko/API-reference.md | 15 ++++++--------- docs/ko/Plugin.md | 13 +++++++++++++ docs/pt-br/API-reference.md | 15 ++++++--------- docs/pt-br/Plugin.md | 13 +++++++++++++ docs/zh-cn/API-reference.md | 15 ++++++--------- docs/zh-cn/Plugin.md | 13 +++++++++++++ 12 files changed, 117 insertions(+), 57 deletions(-) diff --git a/docs/en/API-reference.md b/docs/en/API-reference.md index 53102fec1..11389f3b2 100644 --- a/docs/en/API-reference.md +++ b/docs/en/API-reference.md @@ -49,15 +49,6 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da - [Is a Dayjs `.isDayjs()`](#is-a-dayjs-isdayjscompared-any) - [UTC](#utc) - [Plugin APIs](#plugin-apis) - - [RelativeTime](#relativetime) - - [IsLeapYear](#isleapyear) - - [WeekOfYear](#weekofyear) - - [IsSameOrAfter](#issameorafter) - - [IsSameOrBefore](#issameorbefore) - - [IsBetween](#isbetween) - - [QuarterOfYear](#quarterofyear) - - [ToArray](#toarray) - - [ToObject](#toobject) ## Parsing @@ -489,3 +480,9 @@ plugin [`ToArray`](./Plugin.md#toarray) `.toObject` to return an `object` with the date's properties. plugin [`ToObject`](./Plugin.md#toobject) + +### MinMax + +`.min` `.max` to compare given dayjs instances. + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index ba60aaa93..c3bc92a8b 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -284,7 +284,7 @@ dayjs('2018-06-27').week(5) // set week ### QuarterOfYear -- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. +- QuarterOfYear adds `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. ```javascript import quarterOfYear from 'dayjs/plugin/quarterOfYear' @@ -344,7 +344,7 @@ dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es') ### ToArray -- ToArray add `.toArray()` API to return an `array` that mirrors the parameters +- ToArray adds `.toArray()` API to return an `array` that mirrors the parameters ```javascript import toArray from 'dayjs/plugin/toArray' @@ -356,7 +356,7 @@ dayjs('2019-01-25').toArray() // [ 2019, 0, 25, 0, 0, 0, 0 ] ### ToObject -- ToObject add `.toObject()` API to return an `object` with the date's properties. +- ToObject adds `.toObject()` API to return an `object` with the date's properties. ```javascript import toObject from 'dayjs/plugin/toObject' @@ -373,6 +373,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## Customize You could build your own Day.js plugin to meet different needs. diff --git a/docs/es-es/API-reference.md b/docs/es-es/API-reference.md index d26c925a4..03571033c 100644 --- a/docs/es-es/API-reference.md +++ b/docs/es-es/API-reference.md @@ -49,15 +49,6 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere - [Es Dayjs `.isDayjs()`](#es-dayjs-isdayjscompared-any) - [UTC](#utc) - [API de complementos](#api-de-complementos) - - [RelativeTime](#relativetime) - - [IsLeapYear](#isleapyear) - - [WeekOfYear](#weekofyear) - - [IsSameOrAfter](#issameorafter) - - [IsSameOrBefore](#issameorbefore) - - [IsBetween](#isbetween) - - [QuarterOfYear](#quarterofyear) - - [ToArray](#toarray) - - [ToObject](#toobject) ## Análisis @@ -489,3 +480,9 @@ plugin [`ToArray`](./Plugin.md#toarray) `.toObject` to return an `object` with the date's properties. plugin [`ToObject`](./Plugin.md#toobject) + +### MinMax + +`.min` `.max` to compare given dayjs instances. + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/es-es/Plugin.md b/docs/es-es/Plugin.md index c78bc4e6d..04331ab1e 100644 --- a/docs/es-es/Plugin.md +++ b/docs/es-es/Plugin.md @@ -373,6 +373,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## Personalización Puedes construir tu propio complemento de Day.js para cubrir tus necesidades. diff --git a/docs/ja/API-reference.md b/docs/ja/API-reference.md index 57daefcbe..6b4325517 100644 --- a/docs/ja/API-reference.md +++ b/docs/ja/API-reference.md @@ -46,15 +46,6 @@ Day.js は組み込みの `Date.prototype` を変更する代わりに `Dayjs` - [Is a Dayjs](#is-a-dayjs) - [UTC](#utc) - [Plugin APIs](#plugin-apis) - - [RelativeTime](#relativetime) - - [IsLeapYear](#isleapyear) - - [WeekOfYear](#weekofyear) - - [IsSameOrAfter](#issameorafter) - - [IsSameOrBefore](#issameorbefore) - - [IsBetween](#isbetween) - - [QuarterOfYear](#quarterofyear) - - [ToArray](#toarray) - - [ToObject](#toobject) --- @@ -545,3 +536,9 @@ plugin [`ToArray`](./Plugin.md#toarray) `.toObject` to return an `object` with the date's properties. plugin [`ToObject`](./Plugin.md#toobject) + +### MinMax + +`.min` `.max` to compare given dayjs instances. + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index faabaebbf..57cf9c507 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -382,6 +382,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## カスタマイズ さまざまなニーズに合わせて独自の Day.js プラグインを構築することができます。 diff --git a/docs/ko/API-reference.md b/docs/ko/API-reference.md index 01fa80488..9f4260d54 100644 --- a/docs/ko/API-reference.md +++ b/docs/ko/API-reference.md @@ -48,15 +48,6 @@ Day.js는 네이티브 `Date.prototype`을 수정하는 대신 `Dayjs` 오브젝 - [Is a Dayjs `.isDayjs()`](#is-a-dayjs-isdayjscompared-any) - [UTC](#utc) - [Plugin APIs](#plugin-apis) - - [RelativeTime](#relativetime) - - [IsLeapYear](#isleapyear) - - [WeekOfYear](#weekofyear) - - [IsSameOrAfter](#issameorafter) - - [IsSameOrBefore](#issameorbefore) - - [IsBetween](#isbetween) - - [QuarterOfYear](#quarterofyear) - - [ToArray](#toarray) - - [ToObject](#toobject) ## Parsing @@ -488,3 +479,9 @@ plugin [`ToArray`](./Plugin.md#toarray) `.toObject` to return an `object` with the date's properties. plugin [`ToObject`](./Plugin.md#toobject) + +### MinMax + +`.min` `.max` to compare given dayjs instances. + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index c91449ed3..ecc92586b 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -374,6 +374,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## Customize 다양한 요구를 충족하기위해 자신만의 Day.js 플러그인을 만들 수 있습니다. diff --git a/docs/pt-br/API-reference.md b/docs/pt-br/API-reference.md index 2213127c4..b3843218b 100644 --- a/docs/pt-br/API-reference.md +++ b/docs/pt-br/API-reference.md @@ -49,15 +49,6 @@ O objeto `Dayjs` é imutável, ou seja, todas as operações da API que alteram - [É um objeto `Dayjs` `.isDayjs()`](#é-um-objeto-dayjs-isdayjs) - [UTC](#utc) - [Plugin APIs](#plugin-apis) - - [RelativeTime](#relativetime) - - [IsLeapYear](#isleapyear) - - [WeekOfYear](#weekofyear) - - [IsSameOrAfter](#issameorafter) - - [IsSameOrBefore](#issameorbefore) - - [IsBetween](#isbetween) - - [QuarterOfYear](#quarterofyear) - - [ToArray](#toarray) - - [ToObject](#toobject) ## Conversões @@ -487,3 +478,9 @@ plugin [`ToArray`](./Plugin.md#toarray) `.toObject` to return an `object` with the date's properties. plugin [`ToObject`](./Plugin.md#toobject) + +### MinMax + +`.min` `.max` to compare given dayjs instances. + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index 7a5c7611f..97285b9b5 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -373,6 +373,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## Customizar Você também pode construir seu próprio plugin Day.js para diferentes necessidades. diff --git a/docs/zh-cn/API-reference.md b/docs/zh-cn/API-reference.md index aa96f2891..2aae96bd5 100644 --- a/docs/zh-cn/API-reference.md +++ b/docs/zh-cn/API-reference.md @@ -46,15 +46,6 @@ - [是否是 Dayjs `.isDayjs()`](#是否是-dayjs-isdayjscompared-any) - [UTC](#utc) - [插件 APIs](#plugin-apis) - - [相对时间](#relativetime) - - [是否是闰年](#是否是闰年) - - [年中的第几周](#年中的第几周) - - [是否相同或之后](#是否相同或之后) - - [是否相同或之前](#是否相同或之前) - - [是否之间](#是否之间) - - [年中第几季度](#年中第几季度) - - [转成数组](#转成数组) - - [转成对象](#转成对象) --- @@ -540,3 +531,9 @@ dayjs() instanceof dayjs // true `.toObject` 返回包含时间数值的对象 插件 [`ToObject`](./Plugin.md#toobject) + +### 最小最大 + +`.min` `.max` 比较传入的 dayjs 实例的大小 + +plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 486756cfa..5eb76b6e8 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -372,6 +372,19 @@ dayjs('2019-01-25').toObject() milliseconds: 0 } */ ``` +### MinMax + +- MinMax 增加了 `.min` `.max` API 返回一个 `dayjs` 来比较传入的 dayjs 实例的大小. + +```javascript +import minMax from 'dayjs/plugin/minMax' + +dayjs.extend(minMax) + +dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) +dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) +``` + ## 自定义 你可以根据需要自由的编写一个 Day.js 插件 From 2db8631bd530a2d25528bf99d31ee678816936d1 Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 28 Mar 2019 18:59:43 +0800 Subject: [PATCH 05/17] fix: Add isoWeeksInYear plugin --- src/plugin/isoWeeksInYear/index.js | 12 ++++++++++++ test/plugin/isoWeeksInYear.test.js | 30 ++++++++++++++++++++++++++++++ types/plugin/isoWeeksInYear.d.ts | 10 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/plugin/isoWeeksInYear/index.js create mode 100644 test/plugin/isoWeeksInYear.test.js create mode 100644 types/plugin/isoWeeksInYear.d.ts diff --git a/src/plugin/isoWeeksInYear/index.js b/src/plugin/isoWeeksInYear/index.js new file mode 100644 index 000000000..644f934fb --- /dev/null +++ b/src/plugin/isoWeeksInYear/index.js @@ -0,0 +1,12 @@ +export default (o, c) => { + const proto = c.prototype + proto.isoWeeksInYear = function () { + const isLeapYear = this.isLeapYear() + const last = this.endOf('y') + const day = last.day() + if (day === 4 || (isLeapYear && day === 5)) { + return 53 + } + return 52 + } +} diff --git a/test/plugin/isoWeeksInYear.test.js b/test/plugin/isoWeeksInYear.test.js new file mode 100644 index 000000000..061120ca1 --- /dev/null +++ b/test/plugin/isoWeeksInYear.test.js @@ -0,0 +1,30 @@ +import MockDate from 'mockdate' +import dayjs from '../../src' +import isoWeeksInYear from '../../src/plugin/isoWeeksInYear' +import isLeapYear from '../../src/plugin/isLeapYear' + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +beforeEach(() => { + MockDate.set(new Date()) +}) + +afterEach(() => { + MockDate.reset() +}) + +it('isoWeeksInYear', () => { + expect(dayjs('2004').isoWeeksInYear()).toBe(53) + expect(dayjs('2005').isoWeeksInYear()).toBe(52) + expect(dayjs('2006').isoWeeksInYear()).toBe(52) + expect(dayjs('2007').isoWeeksInYear()).toBe(52) + expect(dayjs('2008').isoWeeksInYear()).toBe(52) + expect(dayjs('2009').isoWeeksInYear()).toBe(53) + expect(dayjs('2010').isoWeeksInYear()).toBe(52) + expect(dayjs('2011').isoWeeksInYear()).toBe(52) + expect(dayjs('2012').isoWeeksInYear()).toBe(52) + expect(dayjs('2013').isoWeeksInYear()).toBe(52) + expect(dayjs('2014').isoWeeksInYear()).toBe(52) + expect(dayjs('2015').isoWeeksInYear()).toBe(53) +}) diff --git a/types/plugin/isoWeeksInYear.d.ts b/types/plugin/isoWeeksInYear.d.ts new file mode 100644 index 000000000..2bc02cddf --- /dev/null +++ b/types/plugin/isoWeeksInYear.d.ts @@ -0,0 +1,10 @@ +import { PluginFunc } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + isoWeeksInYear(): number + } +} From 71e4bff9d874eb6ac3447a06debc938bfc881554 Mon Sep 17 00:00:00 2001 From: iamkun Date: Thu, 28 Mar 2019 19:11:33 +0800 Subject: [PATCH 06/17] docs: Add IsoWeeksInYear docs --- docs/en/API-reference.md | 10 ++++++++-- docs/en/Plugin.md | 15 +++++++++++++++ docs/es-es/API-reference.md | 6 ++++++ docs/es-es/Plugin.md | 15 +++++++++++++++ docs/ja/API-reference.md | 6 ++++++ docs/ja/Plugin.md | 15 +++++++++++++++ docs/ko/API-reference.md | 6 ++++++ docs/ko/Plugin.md | 15 +++++++++++++++ docs/pt-br/API-reference.md | 6 ++++++ docs/pt-br/Plugin.md | 15 +++++++++++++++ docs/zh-cn/API-reference.md | 6 ++++++ docs/zh-cn/Plugin.md | 15 +++++++++++++++ 12 files changed, 128 insertions(+), 2 deletions(-) diff --git a/docs/en/API-reference.md b/docs/en/API-reference.md index 11389f3b2..a95bfe18f 100644 --- a/docs/en/API-reference.md +++ b/docs/en/API-reference.md @@ -445,6 +445,12 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear) plugin [`WeekOfYear`](./Plugin.md#weekofyear) +### IsoWeeksInYear + +`.isoWeeksInYear` to get the number of weeks in year + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + ### IsSameOrAfter `.isSameOrAfter` to check if a date is same of after another date @@ -477,12 +483,12 @@ plugin [`ToArray`](./Plugin.md#toarray) ### ToObject -`.toObject` to return an `object` with the date's properties. +`.toObject` to return an `object` with the date's properties plugin [`ToObject`](./Plugin.md#toobject) ### MinMax -`.min` `.max` to compare given dayjs instances. +`.min` `.max` to compare given dayjs instances plugin [`MinMax`](./Plugin.md#minmax) diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index c3bc92a8b..3df237257 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -282,6 +282,21 @@ dayjs('2018-06-27').week() // 26 dayjs('2018-06-27').week(5) // set week ``` +### IsoWeeksInYear + +- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks. + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear adds `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. diff --git a/docs/es-es/API-reference.md b/docs/es-es/API-reference.md index 03571033c..8d3b1a31e 100644 --- a/docs/es-es/API-reference.md +++ b/docs/es-es/API-reference.md @@ -445,6 +445,12 @@ complemento [`IsLeapYear`](./Plugin.md#isleapyear) complemento [`WeekOfYear`](./Plugin.md#weekofyear) +### IsoWeeksInYear + +`.isoWeeksInYear` to get the number of weeks in year + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + ### IsSameOrAfter `.isSameOrAfter` to check if a date is same of after another date diff --git a/docs/es-es/Plugin.md b/docs/es-es/Plugin.md index 04331ab1e..279c5c85c 100644 --- a/docs/es-es/Plugin.md +++ b/docs/es-es/Plugin.md @@ -282,6 +282,21 @@ dayjs('2018-06-27').week() // 26 dayjs('2018-06-27').week(5) // set week ``` +### IsoWeeksInYear + +- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks. + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. diff --git a/docs/ja/API-reference.md b/docs/ja/API-reference.md index 6b4325517..37fbcf409 100644 --- a/docs/ja/API-reference.md +++ b/docs/ja/API-reference.md @@ -501,6 +501,12 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear) plugin [`WeekOfYear`](./Plugin.md#weekofyear) +### IsoWeeksInYear + +`.isoWeeksInYear` to get the number of weeks in year + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + #### IsSameOrAfter `.isSameOrAfter` はある日付が別の日付と同じまたは以降かどうかを判定します。 diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index 57cf9c507..d29c57f63 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -291,6 +291,21 @@ dayjs('06/27/2018').week() // 26 dayjs('2018-06-27').week(5) // set week ``` +### IsoWeeksInYear + +- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks. + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. diff --git a/docs/ko/API-reference.md b/docs/ko/API-reference.md index 9f4260d54..a5f40ef0a 100644 --- a/docs/ko/API-reference.md +++ b/docs/ko/API-reference.md @@ -444,6 +444,12 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear) plugin [`WeekOfYear`](./Plugin.md#weekofyear) +### IsoWeeksInYear + +`.isoWeeksInYear` to get the number of weeks in year + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + ### IsSameOrAfter `.isSameOrAfter` to check if a date is same of after another date diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index ecc92586b..91a705870 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -283,6 +283,21 @@ dayjs('06/27/2018').week() // 26 dayjs('2018-06-27').week(5) // set week ``` +### IsoWeeksInYear + +- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks. + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. diff --git a/docs/pt-br/API-reference.md b/docs/pt-br/API-reference.md index b3843218b..d14c7958d 100644 --- a/docs/pt-br/API-reference.md +++ b/docs/pt-br/API-reference.md @@ -443,6 +443,12 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear) plugin [`WeekOfYear`](./Plugin.md#weekofyear) +### IsoWeeksInYear + +`.isoWeeksInYear` to get the number of weeks in year + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + ### IsSameOrAfter `.isSameOrAfter` to check if a date is same of after another date diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index 97285b9b5..dfcb55499 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -282,6 +282,21 @@ dayjs('06/27/2018').week() // 26 dayjs('2018-06-27').week(5) // set week ``` +### IsoWeeksInYear + +- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks. + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`. diff --git a/docs/zh-cn/API-reference.md b/docs/zh-cn/API-reference.md index 2aae96bd5..75c7a3d0a 100644 --- a/docs/zh-cn/API-reference.md +++ b/docs/zh-cn/API-reference.md @@ -496,6 +496,12 @@ dayjs() instanceof dayjs // true 插件 [`WeekOfYear`](./Plugin.md#weekofyear) +### 年中有几周 ISO + +`.isoWeeksInYear` 获得年中有几周 + +plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) + ### 是否相同或之后 `.isSameOrAfter` 返回一个时间和一个时间相同或在一个时间之后 diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 5eb76b6e8..49b0a65ab 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -281,6 +281,21 @@ dayjs('06/27/2018').week() // 26 dayjs('2018-06-27').week(5) // 设置周 ``` +### IsoWeeksInYear + +- IsoWeeksInYear 增加了 `.isoWeeksInYear()` API 返回一个 `number` 来得到依据 ISO week 标准一年中有几周 + +```javascript +import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear' +import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin + +dayjs.extend(isoWeeksInYear) +dayjs.extend(isLeapYear) + +dayjs('2004-01-01').isoWeeksInYear() // 53 +dayjs('2005-01-01').isoWeeksInYear() // 52 +``` + ### QuarterOfYear - QuarterOfYear 增加了 `.quarter()` API 返回一个 `number` 来表示 `Dayjs` 的日期是第几个季度,并扩展了 `.add` `.subtract` `.startOf` `.endOf` API 来支持 `quarter` 季度单位。 From d1b9cf97cc77e9ec45ddd7349076a44b2ab9c165 Mon Sep 17 00:00:00 2001 From: iamkun Date: Fri, 29 Mar 2019 15:46:02 +0800 Subject: [PATCH 07/17] fix: Add Calendar plugin --- src/plugin/calendar/index.js | 29 +++++++++++++ test/plugin/calendar.test.js | 81 ++++++++++++++++++++++++++++++++++++ types/plugin/calendar.d.ts | 10 +++++ 3 files changed, 120 insertions(+) create mode 100644 src/plugin/calendar/index.js create mode 100644 test/plugin/calendar.test.js create mode 100644 types/plugin/calendar.d.ts diff --git a/src/plugin/calendar/index.js b/src/plugin/calendar/index.js new file mode 100644 index 000000000..87db1894a --- /dev/null +++ b/src/plugin/calendar/index.js @@ -0,0 +1,29 @@ +export default (o, c, d) => { + const LT = 'h:mm A' + const L = 'MM/DD/YYYY' + const calendarFormat = { + lastDay: `[Yesterday at] ${LT}`, + sameDay: `[Today at] ${LT}`, + nextDay: `[Tomorrow at] ${LT}`, + nextWeek: `dddd [at] ${LT}`, + lastWeek: `[Last] dddd [at] ${LT}`, + sameElse: L + } + const proto = c.prototype + proto.calendar = function (referenceTime, formats) { + const format = formats || calendarFormat + const referenceStartOfDay = d(referenceTime || undefined).startOf('d') + const diff = this.diff(referenceStartOfDay, 'd', true) + const sameElse = 'sameElse' + /* eslint-disable no-nested-ternary */ + const retVal = diff < -6 ? sameElse : + diff < -1 ? 'lastWeek' : + diff < 0 ? 'lastDay' : + diff < 1 ? 'sameDay' : + diff < 2 ? 'nextDay' : + diff < 7 ? 'nextWeek' : sameElse + /* eslint-enable no-nested-ternary */ + return this.format(format[retVal] || calendarFormat[retVal]) + } +} + diff --git a/test/plugin/calendar.test.js b/test/plugin/calendar.test.js new file mode 100644 index 000000000..24dec0f7e --- /dev/null +++ b/test/plugin/calendar.test.js @@ -0,0 +1,81 @@ +import MockDate from 'mockdate' +import moment from 'moment' +import dayjs from '../../src' +import calendar from '../../src/plugin/calendar' + +dayjs.extend(calendar) + +beforeEach(() => { + MockDate.set(new Date()) +}) + +afterEach(() => { + MockDate.reset() +}) + +it('No argument && null && undefined', () => { + expect(dayjs().calendar()).toEqual(moment().calendar()) + expect(dayjs().calendar(null)).toEqual(moment().calendar(null)) + expect(dayjs().calendar(undefined)).toEqual(moment().calendar(undefined)) +}) + +it('ReferenceTime', () => { + const now = '2015-01-15T14:21:22.000Z' + const dates = [ + { + name: 'nextDay', + date: '2015-01-14T11:23:55.000Z', + result: 'Tomorrow' + }, + { + name: 'sameDay', + date: '2015-01-15T11:23:55.000Z', + result: 'Today' + }, + { + name: 'nextWeek', + date: '2015-01-09T11:23:55.000Z', + result: 'Thursday' + }, + { + name: 'lastDay', + date: '2015-01-16T11:23:55.000Z', + result: 'Yesterday' + }, + { + name: 'lastWeek', + date: '2015-01-21T11:23:55.000Z', + result: 'Last' + }, + { + name: 'sameElse', + date: '2015-01-01T11:23:55.000Z', + result: '01/15/2015' + }, + { + name: 'sameElse', + date: '2015-02-21T11:23:55.000Z', + result: '01/15/2015' + } + ] + dates.forEach((d) => { + const dayjsResult = dayjs(now).calendar(d.date) + const momentjsResult = moment(now).calendar(d.date) + expect(dayjsResult) + .toEqual(momentjsResult) + expect(dayjsResult.indexOf(d.result) > -1) + .toBe(true) + }) +}) + +it('Custom format', () => { + const format = { + sameDay: '[sameDay]', + sameElse: '[sameElse]' + } + expect(dayjs().calendar(null, format)).toEqual(moment().calendar(null, format)) + const now = '2015-01-15T14:21:22.000Z' + const nextDayWithoutFormat = '2015-01-14T11:23:55.000Z' + expect(dayjs(now).calendar(nextDayWithoutFormat, format)) + .toEqual(moment(now).calendar(nextDayWithoutFormat, format)) +}) diff --git a/types/plugin/calendar.d.ts b/types/plugin/calendar.d.ts new file mode 100644 index 000000000..a8d064fd6 --- /dev/null +++ b/types/plugin/calendar.d.ts @@ -0,0 +1,10 @@ +import { PluginFunc, ConfigType } from 'dayjs' + +declare const plugin: PluginFunc +export = plugin + +declare module 'dayjs' { + interface Dayjs { + calendar(referenceTime?: ConfigType, formats?: object): string + } +} From d058f4a339cac60852ad4965dbdaea7e75e0fb03 Mon Sep 17 00:00:00 2001 From: iamkun Date: Fri, 29 Mar 2019 17:59:55 +0800 Subject: [PATCH 08/17] fix: Fix set Month Year error in last day of the month --- src/index.js | 16 ++++++++-------- test/get-set.test.js | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index ffdbe9671..780ad3ba1 100644 --- a/src/index.js +++ b/src/index.js @@ -218,7 +218,12 @@ class Dayjs { }[unit] const arg = unit === C.D ? this.$D + (int - this.$W) : int - if (this.$d[name]) this.$d[name](arg) + if (unit === C.M || unit === C.Y) { + const date = this.clone().set(C.DATE, 1) + date.$d[name](arg) + date.init() + this.$d = date.set(C.DATE, Math.min(this.$D, date.daysInMonth())).toDate() + } else if (name) this.$d[name](arg) this.init() return this @@ -231,21 +236,16 @@ class Dayjs { add(number, units) { number = Number(number) // eslint-disable-line no-param-reassign const unit = Utils.p(units) - const instanceFactory = (u, n) => { - // clone is for badMutable plugin - const date = this.clone().set(C.DATE, 1).set(u, n + number) - return date.set(C.DATE, Math.min(this.$D, date.daysInMonth())) - } const instanceFactorySet = (n) => { const date = new Date(this.$d) date.setDate(date.getDate() + (n * number)) return Utils.w(date, this) } if (unit === C.M) { - return instanceFactory(C.M, this.$M) + return this.set(C.M, this.$M + number) } if (unit === C.Y) { - return instanceFactory(C.Y, this.$y) + return this.set(C.Y, this.$y + number) } if (unit === C.D) { return instanceFactorySet(1) diff --git a/test/get-set.test.js b/test/get-set.test.js index 7587915cf..cf604df77 100644 --- a/test/get-set.test.js +++ b/test/get-set.test.js @@ -90,6 +90,21 @@ it('Set Millisecond', () => { expect(dayjs().set('millisecond', 999).valueOf()).toBe(moment().set('millisecond', 999).valueOf()) }) +it('Set Month and Year in last day of month', () => { + // 2011-07-31 -> 2011-02-28 + const origin = dayjs('2011-07-31T14:48:00.000Z') + const setMonth = origin.set('month', 1) + expect(setMonth.month()).toBe(1) + expect(origin.date()).toBe(31) + expect(setMonth.date()).toBe(28) + // 2000-02-29 -> 2001-02-28 + const origin2 = dayjs('2000-02-29T14:48:00.000Z') + const setYear = origin2.set('year', 2001) + expect(setYear.month()).toBe(1) + expect(origin2.date()).toBe(29) + expect(setYear.date()).toBe(28) +}) + it('Set Unknown String', () => { const newDate = dayjs().set('Unknown String', 1) expect(newDate.valueOf()) From e925de675f2a24e2145560e1f520cf839837f7a1 Mon Sep 17 00:00:00 2001 From: iamkun Date: Fri, 29 Mar 2019 18:51:59 +0800 Subject: [PATCH 09/17] docs: Add Calendar plugin docs --- docs/en/API-reference.md | 6 ++++++ docs/en/Plugin.md | 20 ++++++++++++++++++++ docs/es-es/API-reference.md | 6 ++++++ docs/es-es/Plugin.md | 20 ++++++++++++++++++++ docs/ja/API-reference.md | 6 ++++++ docs/ja/Plugin.md | 20 ++++++++++++++++++++ docs/ko/API-reference.md | 6 ++++++ docs/ko/Plugin.md | 20 ++++++++++++++++++++ docs/pt-br/API-reference.md | 6 ++++++ docs/pt-br/Plugin.md | 20 ++++++++++++++++++++ docs/zh-cn/API-reference.md | 6 ++++++ docs/zh-cn/Plugin.md | 22 +++++++++++++++++++++- src/index.js | 1 + 13 files changed, 158 insertions(+), 1 deletion(-) diff --git a/docs/en/API-reference.md b/docs/en/API-reference.md index a95bfe18f..1035b8773 100644 --- a/docs/en/API-reference.md +++ b/docs/en/API-reference.md @@ -492,3 +492,9 @@ plugin [`ToObject`](./Plugin.md#toobject) `.min` `.max` to compare given dayjs instances plugin [`MinMax`](./Plugin.md#minmax) + +### Calendar + +`.calendar` to display calendar time + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index 3df237257..5fc968750 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar adds `.calendar` API to return a `string` to display calendar time + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM ) + nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM ) + nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM ) + lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM ) + lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 ) +}) +``` + ## Customize You could build your own Day.js plugin to meet different needs. diff --git a/docs/es-es/API-reference.md b/docs/es-es/API-reference.md index 8d3b1a31e..cde19d343 100644 --- a/docs/es-es/API-reference.md +++ b/docs/es-es/API-reference.md @@ -492,3 +492,9 @@ plugin [`ToObject`](./Plugin.md#toobject) `.min` `.max` to compare given dayjs instances. plugin [`MinMax`](./Plugin.md#minmax) + +### Calendar + +`.calendar` to display calendar time + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/es-es/Plugin.md b/docs/es-es/Plugin.md index 279c5c85c..1b5362afd 100644 --- a/docs/es-es/Plugin.md +++ b/docs/es-es/Plugin.md @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar adds `.calendar` API to return a `string` to display calendar time + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM ) + nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM ) + nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM ) + lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM ) + lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 ) +}) +``` + ## Personalización Puedes construir tu propio complemento de Day.js para cubrir tus necesidades. diff --git a/docs/ja/API-reference.md b/docs/ja/API-reference.md index 37fbcf409..d703fe3cc 100644 --- a/docs/ja/API-reference.md +++ b/docs/ja/API-reference.md @@ -548,3 +548,9 @@ plugin [`ToObject`](./Plugin.md#toobject) `.min` `.max` to compare given dayjs instances. plugin [`MinMax`](./Plugin.md#minmax) + +### Calendar + +`.calendar` to display calendar time + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index d29c57f63..2daa02cb0 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -410,6 +410,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar adds `.calendar` API to return a `string` to display calendar time + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM ) + nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM ) + nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM ) + lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM ) + lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 ) +}) +``` + ## カスタマイズ さまざまなニーズに合わせて独自の Day.js プラグインを構築することができます。 diff --git a/docs/ko/API-reference.md b/docs/ko/API-reference.md index a5f40ef0a..10be81e2e 100644 --- a/docs/ko/API-reference.md +++ b/docs/ko/API-reference.md @@ -491,3 +491,9 @@ plugin [`ToObject`](./Plugin.md#toobject) `.min` `.max` to compare given dayjs instances. plugin [`MinMax`](./Plugin.md#minmax) + +### Calendar + +`.calendar` to display calendar time + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index 91a705870..25c706221 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -402,6 +402,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar adds `.calendar` API to return a `string` to display calendar time + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM ) + nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM ) + nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM ) + lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM ) + lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 ) +}) +``` + ## Customize 다양한 요구를 충족하기위해 자신만의 Day.js 플러그인을 만들 수 있습니다. diff --git a/docs/pt-br/API-reference.md b/docs/pt-br/API-reference.md index d14c7958d..5a7009ef5 100644 --- a/docs/pt-br/API-reference.md +++ b/docs/pt-br/API-reference.md @@ -490,3 +490,9 @@ plugin [`ToObject`](./Plugin.md#toobject) `.min` `.max` to compare given dayjs instances. plugin [`MinMax`](./Plugin.md#minmax) + +### Calendar + +`.calendar` to display calendar time + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index dfcb55499..676cff560 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar adds `.calendar` API to return a `string` to display calendar time + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM ) + nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM ) + nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM ) + lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM ) + lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 ) +}) +``` + ## Customizar Você também pode construir seu próprio plugin Day.js para diferentes necessidades. diff --git a/docs/zh-cn/API-reference.md b/docs/zh-cn/API-reference.md index 75c7a3d0a..4c0c4e5fd 100644 --- a/docs/zh-cn/API-reference.md +++ b/docs/zh-cn/API-reference.md @@ -543,3 +543,9 @@ plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear) `.min` `.max` 比较传入的 dayjs 实例的大小 plugin [`MinMax`](./Plugin.md#minmax) + +### 日历时间 + +`.calendar` 来显示日历时间 + +plugin [`Calendar`](./Plugin.md#calendar) diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 49b0a65ab..89caccc6b 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -389,7 +389,7 @@ dayjs('2019-01-25').toObject() ### MinMax -- MinMax 增加了 `.min` `.max` API 返回一个 `dayjs` 来比较传入的 dayjs 实例的大小. +- MinMax 增加了 `.min` `.max` API 返回一个 `dayjs` 来比较传入的 dayjs 实例的大小。 ```javascript import minMax from 'dayjs/plugin/minMax' @@ -400,6 +400,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')) dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')]) ``` +### Calendar + +- Calendar 增加了 `.calendar` API 返回一个 `string` 来显示日历时间。 + +```javascript +import calendar from 'dayjs/plugin/calendar' + +dayjs.extend(calendar) + +dayjs().calendar(dayjs('2008-01-01')) +dayjs().calendar(null, { + sameDay: '[今天] HH:mm', // 今天 ( 今天 2:30 AM ) + nextDay: '[明天]', // 明天 ( 明天 2:30 AM ) + nextWeek: '[下]dddd', // 下周 ( Sunday at 2:30 AM ) + lastDay: '[昨天]', // 昨天 ( 昨天 2:30 AM ) + lastWeek: '[上] dddd', // 上周 ( Last Monday at 2:30 AM ) + sameElse: 'DD/MM/YYYY' // 其他情况 ( 7/10/2011 ) +}) +``` + ## 自定义 你可以根据需要自由的编写一个 Day.js 插件 diff --git a/src/index.js b/src/index.js index 780ad3ba1..d0213dedb 100644 --- a/src/index.js +++ b/src/index.js @@ -219,6 +219,7 @@ class Dayjs { const arg = unit === C.D ? this.$D + (int - this.$W) : int if (unit === C.M || unit === C.Y) { + // clone is for badMutable plugin const date = this.clone().set(C.DATE, 1) date.$d[name](arg) date.init() From 73187972c7265785c93d4d4c9e8d079143d777fd Mon Sep 17 00:00:00 2001 From: iamkun Date: Mon, 1 Apr 2019 16:17:09 +0800 Subject: [PATCH 10/17] fix: Add .get API --- src/index.js | 4 ++++ test/get-set.test.js | 8 ++++++++ types/index.d.ts | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/index.js b/src/index.js index d0213dedb..6ad4e5a1e 100644 --- a/src/index.js +++ b/src/index.js @@ -234,6 +234,10 @@ class Dayjs { return this.clone().$set(string, int) } + get(unit) { + return this[Utils.p(unit)]() + } + add(number, units) { number = Number(number) // eslint-disable-line no-param-reassign const unit = Utils.p(units) diff --git a/test/get-set.test.js b/test/get-set.test.js index cf604df77..dae4d476c 100644 --- a/test/get-set.test.js +++ b/test/get-set.test.js @@ -11,48 +11,56 @@ afterEach(() => { }) it('Year', () => { + expect(dayjs().get('year')).toBe(moment().get('year')) expect(dayjs().year()).toBe(moment().year()) expect(dayjs().year(0).valueOf()).toBe(moment().year(0).valueOf()) expect(dayjs().year(2000).valueOf()).toBe(moment().year(2000).valueOf()) }) it('Month', () => { + expect(dayjs().get('month')).toBe(moment().get('month')) expect(dayjs().month()).toBe(moment().month()) expect(dayjs().month(0).valueOf()).toBe(moment().month(0).valueOf()) expect(dayjs().month(1).valueOf()).toBe(moment().month(1).valueOf()) }) it('Day of Week', () => { + expect(dayjs().get('day')).toBe(moment().get('day')) expect(dayjs().day()).toBe(moment().day()) expect(dayjs().day(0).format()).toBe(moment().day(0).format()) expect(dayjs().day(1).format()).toBe(moment().day(1).format()) }) it('Date', () => { + expect(dayjs().get('date')).toBe(moment().get('date')) expect(dayjs().date()).toBe(moment().date()) expect(dayjs().date(0).valueOf()).toBe(moment().date(0).valueOf()) expect(dayjs().date(1).valueOf()).toBe(moment().date(1).valueOf()) }) it('Hour', () => { + expect(dayjs().get('hour')).toBe(moment().get('hour')) expect(dayjs().hour()).toBe(moment().hour()) expect(dayjs().hour(0).valueOf()).toBe(moment().hour(0).valueOf()) expect(dayjs().hour(1).valueOf()).toBe(moment().hour(1).valueOf()) }) it('Minute', () => { + expect(dayjs().get('minute')).toBe(moment().get('minute')) expect(dayjs().minute()).toBe(moment().minute()) expect(dayjs().minute(0).valueOf()).toBe(moment().minute(0).valueOf()) expect(dayjs().minute(1).valueOf()).toBe(moment().minute(1).valueOf()) }) it('Second', () => { + expect(dayjs().get('second')).toBe(moment().get('second')) expect(dayjs().second()).toBe(moment().second()) expect(dayjs().second(0).valueOf()).toBe(moment().second(0).valueOf()) expect(dayjs().second(1).valueOf()).toBe(moment().second(1).valueOf()) }) it('Millisecond', () => { + expect(dayjs().get('millisecond')).toBe(moment().get('millisecond')) expect(dayjs().millisecond()).toBe(moment().millisecond()) expect(dayjs().millisecond(0).valueOf()).toBe(moment().millisecond(0).valueOf()) expect(dayjs().millisecond(1).valueOf()).toBe(moment().millisecond(1).valueOf()) diff --git a/types/index.d.ts b/types/index.d.ts index f32c4c003..6473865c6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -53,6 +53,8 @@ declare namespace dayjs { set(unit: UnitType, value: number): Dayjs + get(unit: UnitType): number + add(value: number, unit: OpUnitType): Dayjs subtract(value: number, unit: OpUnitType): Dayjs From daae556f91b623c6b05b2340c6e73f4211aba907 Mon Sep 17 00:00:00 2001 From: iamkun Date: Mon, 1 Apr 2019 16:29:39 +0800 Subject: [PATCH 11/17] docs: Update .get docs --- docs/en/API-reference.md | 24 +++++++++++++++++------- docs/es-es/API-reference.md | 12 +++++++++++- docs/ja/API-reference.md | 25 +++++++++++++++++-------- docs/ko/API-reference.md | 20 +++++++++++++++----- docs/pt-br/API-reference.md | 22 ++++++++++++++++------ docs/zh-cn/API-reference.md | 23 ++++++++++++++++------- 6 files changed, 92 insertions(+), 34 deletions(-) diff --git a/docs/en/API-reference.md b/docs/en/API-reference.md index 1035b8773..f1140abe0 100644 --- a/docs/en/API-reference.md +++ b/docs/en/API-reference.md @@ -23,8 +23,9 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da - [Minute `.minute()`](#minute-minute) - [Second `.second()`](#second-second) - [Millisecond `.millisecond()`](#millisecond-millisecond) - - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) + - [Get `.get(unit: string)`](#get-getunit-string) - [List of all available units](#list-of-all-available-units) + - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) - [Manipulating](#manipulating) - [Add `.add(value: number, unit: string)`](#add-addvalue-number-unit-string) - [Subtract `.subtract(value: number, unit: string)`](#subtract-subtractvalue-number-unit-string) @@ -186,14 +187,13 @@ dayjs().millisecond() dayjs().millisecond(1) ``` -### Set `.set(unit: string, value: number)` +### Get `.get(unit: string)` -Returns a `Dayjs` with the applied changes. +Returns a `number` with information getting from `Dayjs` object ```js -dayjs().set('date', 1) -dayjs().set('month', 3) // April -dayjs().set('second', 30) +dayjs().get('month') // start 0 +dayjs().get('day') ``` #### List of all available units @@ -209,9 +209,19 @@ dayjs().set('second', 30) | `second` | `s` | Second | | `millisecond` | `ms` | Millisecond | +### Set `.set(unit: string, value: number)` + +Returns a `Dayjs` with the applied changes. + +```js +dayjs().set('date', 1) +dayjs().set('month', 3) // April +dayjs().set('second', 30) +``` + ## Manipulating -`Dayjs` objects can be manipulated in many ways. +`Dayjs` object can be manipulated in many ways. ```js dayjs('2019-01-25') diff --git a/docs/es-es/API-reference.md b/docs/es-es/API-reference.md index cde19d343..1d4cd2f5a 100644 --- a/docs/es-es/API-reference.md +++ b/docs/es-es/API-reference.md @@ -23,8 +23,9 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere - [Minuto `.minute()`](#minuto-minute) - [Segundo `.second()`](#segundo-second) - [Milisegundo `.millisecond()`](#milisegundo-millisecond) - - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) + - [Get `.get(unit: string)`](#get-getunit-string) - [Lista de unidades disponibles](#lista-de-unidades-disponibles) + - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) - [Manipulación](#manipulación) - [Añadir `.add(value: number, unit: string)`](#añadir-addvalue-number-unit-string) - [Restar `.subtract(value: number, unit: string)`](#restar-subtractvalue-number-unit-string) @@ -186,6 +187,15 @@ dayjs().millisecond() dayjs().millisecond(1) ``` +### Get `.get(unit: string)` + +Returns a `number` with information getting from `Dayjs` object + +```js +dayjs().get('month') // start 0 +dayjs().get('day') +``` + ### Set `.set(unit: string, value: number)` Devuelve un nuevo objeto `Dayjs` con los cambios aplicados. diff --git a/docs/ja/API-reference.md b/docs/ja/API-reference.md index d703fe3cc..92a439b31 100644 --- a/docs/ja/API-reference.md +++ b/docs/ja/API-reference.md @@ -22,6 +22,7 @@ Day.js は組み込みの `Date.prototype` を変更する代わりに `Dayjs` - [Minute](#minute) - [Second](#second) - [Millisecond](#millisecond) + - [Get](#get) - [Set](#set) - [Manipulate](#manipulate) - [Add](#add) @@ -199,16 +200,15 @@ dayjs().millisecond() dayjs().millisecond(1) ``` -#### Set +#### Get -日付のセッターです。 +Returns a `number` with information getting from `Dayjs` object 単位は大文字・小文字を区別しません。 ```js -dayjs().set((unit: String), (value: Int)) -dayjs().set('date', 1) -dayjs().set('month', 3) // 4月 -dayjs().set('second', 30) +dayjs().get(unit: String) +dayjs().get('month') // start 0 +dayjs().get('day') ``` #### List of all available units @@ -224,7 +224,16 @@ dayjs().set('second', 30) | `second` | `s` | Second | | `millisecond` | `ms` | Millisecond | ---- +#### Set + +日付のセッターです。 + +```js +dayjs().set(unit: String, value: Int) +dayjs().set('date', 1) +dayjs().set('month', 3) // 4月 +dayjs().set('second', 30) +``` ### Manipulate @@ -242,7 +251,7 @@ dayjs() 時間を足して新しい `Dayjs` オブジェクトを返します。 ```js -dayjs().add((value: Number), (unit: String)) +dayjs().add(value: Number, unit: String) dayjs().add(7, 'day') ``` diff --git a/docs/ko/API-reference.md b/docs/ko/API-reference.md index 10be81e2e..6cc73d4a0 100644 --- a/docs/ko/API-reference.md +++ b/docs/ko/API-reference.md @@ -23,6 +23,7 @@ Day.js는 네이티브 `Date.prototype`을 수정하는 대신 `Dayjs` 오브젝 - [Minute `.minute()`](#minute-minute) - [Second `.second()`](#second-second) - [Millisecond `.millisecond()`](#millisecond-millisecond) + - [Get `.get(unit: string)`](#get-getunit-string) - [Set `.set(unit: string, value: number)`](#set-setunit--string--value--number) - [Manipulating](#manipulating) - [Add `.add(value: number, unit: string)`](#add-addvalue--number--unit--string) @@ -185,14 +186,13 @@ dayjs().millisecond() dayjs().millisecond(1) ``` -### Set `.set(unit: string, value: number)` +### Get `.get(unit: string)` -변경 사항이 적용된 `Dayjs`를 반환합니다. +Returns a `number` with information getting from `Dayjs` object ```js -dayjs().set('date', 1) -dayjs().set('month', 3) // April -dayjs().set('second', 30) +dayjs().get('month') // start 0 +dayjs().get('day') ``` #### List of all available units @@ -208,6 +208,16 @@ dayjs().set('second', 30) | `second` | `s` | Second | | `millisecond` | `ms` | Millisecond | +### Set `.set(unit: string, value: number)` + +변경 사항이 적용된 `Dayjs`를 반환합니다. + +```js +dayjs().set('date', 1) +dayjs().set('month', 3) // April +dayjs().set('second', 30) +``` + ## Manipulating `Dayjs` 오브젝트는 여러 방법으로 처리할 수 있습니다. diff --git a/docs/pt-br/API-reference.md b/docs/pt-br/API-reference.md index 5a7009ef5..5e1002340 100644 --- a/docs/pt-br/API-reference.md +++ b/docs/pt-br/API-reference.md @@ -23,8 +23,9 @@ O objeto `Dayjs` é imutável, ou seja, todas as operações da API que alteram - [Minuto `.minute()`](#minuto-minute) - [Segundo `.second()`](#segundo-second) - [Milissegundo `.millisecond()`](#milissegundo-millisecond) - - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) + - [Get `.get(unit: string)`](#get-getunit-string) - [Lista de todas as unidades disponíveis](#lista-de-todas-as-unidades-disponíveis) + - [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number) - [Manipulando](#manipulando) - [Adicionar `.add(value: number, unit: string)`](#adicionar-addvalue-number-unit-string) - [Subtrair `.subtract(value: number, unit: string)`](#subtrair-subtractvalue-number-unit-string) @@ -184,14 +185,13 @@ dayjs().millisecond() dayjs().millisecond(1) ``` -### Set `.set(unit: string, value: number)` +### Get `.get(unit: string)` -Retorna um `Dayjs` com as mudanças aplicadas. +Returns a `number` with information getting from `Dayjs` object ```js -dayjs().set('date', 1) -dayjs().set('month', 3) // April -dayjs().set('second', 30) +dayjs().get('month') // start 0 +dayjs().get('day') ``` #### Lista de todas as unidades disponíveis @@ -207,6 +207,16 @@ dayjs().set('second', 30) | `second` | `s` | Segundo | | `millisecond` | `ms` | Milissegundo | +### Set `.set(unit: string, value: number)` + +Retorna um `Dayjs` com as mudanças aplicadas. + +```js +dayjs().set('date', 1) +dayjs().set('month', 3) // April +dayjs().set('second', 30) +``` + ## Manipulando Um objeto `Dayjs` pode ser manipulado de várias maneiras. diff --git a/docs/zh-cn/API-reference.md b/docs/zh-cn/API-reference.md index 4c0c4e5fd..eb118013e 100644 --- a/docs/zh-cn/API-reference.md +++ b/docs/zh-cn/API-reference.md @@ -22,6 +22,7 @@ - [分](#分) - [秒](#秒) - [毫秒](#毫秒) + - [获取](#获取) - [设置](#设置) - [操作](#操作) - [增加](#增加) @@ -201,16 +202,15 @@ dayjs().millisecond() dayjs().millisecond(1) ``` -#### 设置 +#### 获取 -设置时间 +获取从 `Dayjs` 对象中取到的信息 传入的单位 (unit) 对大小写不敏感。 ```js -dayjs().set(unit : String, value : Int); -dayjs().set('date', 1); -dayjs().set('month', 3); // 四月 -dayjs().set('second', 30); +dayjs().get(unit : String) +dayjs().get('month') // 从 0 开始 +dayjs().get('day') ``` #### 可用单位 @@ -226,7 +226,16 @@ dayjs().set('second', 30); | `second` | `s` | 秒 | | `millisecond` | `ms` | 毫秒 | ---- +#### 设置 + +设置时间 + +```js +dayjs().set(unit : String, value : Int); +dayjs().set('date', 1); +dayjs().set('month', 3); // 四月 +dayjs().set('second', 30); +``` ### 操作 From 3f58237103dba1c1b21781448044da392459ab30 Mon Sep 17 00:00:00 2001 From: iamkun Date: Mon, 1 Apr 2019 16:41:05 +0800 Subject: [PATCH 12/17] docs: Update available units table doc --- docs/en/API-reference.md | 2 +- docs/es-es/API-reference.md | 2 +- docs/ja/API-reference.md | 2 +- docs/ko/API-reference.md | 2 +- docs/pt-br/API-reference.md | 2 +- docs/zh-cn/API-reference.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/API-reference.md b/docs/en/API-reference.md index f1140abe0..75788edee 100644 --- a/docs/en/API-reference.md +++ b/docs/en/API-reference.md @@ -202,7 +202,7 @@ dayjs().get('day') | ------------- | --------- | ---------------------------------------- | | `date` | | Date of Month | | `day` | `d` | Day of Week (Sunday as 0, Saturday as 6) | -| `month` | `M` | Month | +| `month` | `M` | Month (January as 0, December as 11) | | `year` | `y` | Year | | `hour` | `h` | Hour | | `minute` | `m` | Minute | diff --git a/docs/es-es/API-reference.md b/docs/es-es/API-reference.md index 1d4cd2f5a..3c8913700 100644 --- a/docs/es-es/API-reference.md +++ b/docs/es-es/API-reference.md @@ -212,7 +212,7 @@ dayjs().set('second', 30) | ------------- | ----------- | ------------------------------------------- | | `date` | | Día del mes | | `day` | `d` | Día de la semana (de domingo 0, a sábado 6) | -| `month` | `M` | Mes | +| `month` | `M` | Mes (January as 0, December as 11) | | `year` | `y` | Año | | `hour` | `h` | Hora | | `minute` | `m` | Minuto | diff --git a/docs/ja/API-reference.md b/docs/ja/API-reference.md index 92a439b31..c86257732 100644 --- a/docs/ja/API-reference.md +++ b/docs/ja/API-reference.md @@ -217,7 +217,7 @@ dayjs().get('day') | ------------- | --------- | ---------------------------------------- | | `date` | | Date of Month | | `day` | `d` | Day of Week (Sunday as 0, Saturday as 6) | -| `month` | `M` | Month | +| `month` | `M` | Month (January as 0, December as 11) | | `year` | `y` | Year | | `hour` | `h` | Hour | | `minute` | `m` | Minute | diff --git a/docs/ko/API-reference.md b/docs/ko/API-reference.md index 6cc73d4a0..efe06d52b 100644 --- a/docs/ko/API-reference.md +++ b/docs/ko/API-reference.md @@ -201,7 +201,7 @@ dayjs().get('day') | ------------- | --------- | ---------------------------------------- | | `date` | | Date of Month | | `day` | `d` | Day of Week (Sunday as 0, Saturday as 6) | -| `month` | `M` | Month | +| `month` | `M` | Month (January as 0, December as 11) | | `year` | `y` | Year | | `hour` | `h` | Hour | | `minute` | `m` | Minute | diff --git a/docs/pt-br/API-reference.md b/docs/pt-br/API-reference.md index 5e1002340..3617750c0 100644 --- a/docs/pt-br/API-reference.md +++ b/docs/pt-br/API-reference.md @@ -200,7 +200,7 @@ dayjs().get('day') | ------------- | --------- | --------------------------------------------- | | `date` | | Data do Mês | | `day` | `d` | Dia da Semana (Domingo como 0, Sábado como 6) | -| `month` | `M` | Mês | +| `month` | `M` | Mês (January as 0, December as 11) | | `year` | `y` | Ano | | `hour` | `h` | Hora | | `minute` | `m` | Minuto | diff --git a/docs/zh-cn/API-reference.md b/docs/zh-cn/API-reference.md index eb118013e..52d6a2ec5 100644 --- a/docs/zh-cn/API-reference.md +++ b/docs/zh-cn/API-reference.md @@ -219,7 +219,7 @@ dayjs().get('day') | ------------- | ---- | --------------------------- | | `date` | | 日期 | | `day` | `d` | 星期几 (星期天 0, 星期六 6) | -| `month` | `M` | 月 | +| `month` | `M` | 月 (一月 0, 十二月 11) | | `year` | `y` | 年 | | `hour` | `h` | 时 | | `minute` | `m` | 分 | From f2b5ebf73c395020edd0bb1c0b799b7f5f026885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Gon=C3=A7alves?= Date: Mon, 1 Apr 2019 11:58:40 +0100 Subject: [PATCH 13/17] fix: Update localizedFormat plugin to support lowercase localizable formats (l, ll, lll, llll) (#546) --- docs/en/I18n.md | 7 +++++- docs/en/Plugin.md | 4 +++ docs/pt-br/I18n.md | 14 +++++++++++ src/constant.js | 2 +- src/index.js | 5 +--- src/locale/ca.js | 5 +++- src/locale/cs.js | 3 ++- src/locale/fi.js | 12 +++++++++ src/locale/he.js | 14 ++++++++++- src/locale/ja.js | 6 ++++- src/locale/ko.js | 6 ++++- src/locale/lt.js | 12 +++++++++ src/locale/sv.js | 4 ++- src/locale/zh-cn.js | 6 ++++- src/locale/zh-tw.js | 6 ++++- src/plugin/localizedFormat/index.js | 10 +++++--- test/display.test.js | 4 ++- test/locale/keys.test.js | 35 +++++++++++++++++++++++---- test/plugin/localizableFormat.test.js | 17 ++++++++++--- 19 files changed, 146 insertions(+), 26 deletions(-) diff --git a/docs/en/I18n.md b/docs/en/I18n.md index 2f9a8bddb..6226e32f6 100644 --- a/docs/en/I18n.md +++ b/docs/en/I18n.md @@ -100,7 +100,12 @@ const localeObject = { L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', - LLLL: 'dddd, MMMM D, YYYY h:mm A' + LLLL: 'dddd, MMMM D, YYYY h:mm A', + // lowercase/short, optional formats for localization + l: 'D/M/YYYY', + ll: 'D MMM, YYYY', + lll: 'D MMM, YYYY h:mm A', + llll: 'ddd, MMM D, YYYY h:mm A' }, relativeTime: { // relative time format strings, keep %s %d as the same diff --git a/docs/en/Plugin.md b/docs/en/Plugin.md index 5fc968750..c54ec91cd 100644 --- a/docs/en/Plugin.md +++ b/docs/en/Plugin.md @@ -135,6 +135,10 @@ List of added formats: | `LL` | MMMM D, YYYY | August 16, 2018 | | `LLL` | MMMM D, YYYY h:mm A | August 16, 2018 8:02 PM | | `LLLL` | dddd, MMMM D, YYYY h:mm A | Thursday, August 16, 2018 8:02 PM | +| `l` | M/D/YYYY | 8/16/2018 | +| `ll` | MMM D, YYYY | Aug 16, 2018 | +| `lll` | MMM D, YYYY h:mm A | Aug 16, 2018 8:02 PM | +| `llll` | ddd, MMM D, YYYY h:mm A | Thu, Aug 16, 2018 8:02 PM | ### RelativeTime diff --git a/docs/pt-br/I18n.md b/docs/pt-br/I18n.md index 108263524..901b44c4a 100644 --- a/docs/pt-br/I18n.md +++ b/docs/pt-br/I18n.md @@ -93,6 +93,20 @@ const objetoLocale = { 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 + formats: { + // opções para formatos localizados + LTS: 'h:mm:ss A', + LT: 'h:mm A', + L: 'MM/DD/YYYY', + LL: 'MMMM D, YYYY', + LLL: 'MMMM D, YYYY h:mm A', + LLLL: 'dddd, MMMM D, YYYY h:mm A', + // formatos localizados/curtos opcionais + l: 'D/M/YYYY', + ll: 'D MMM, YYYY', + lll: 'D MMM, YYYY h:mm A', + llll: 'ddd, MMM D, YYYY h:mm A' + }, relativeTime: { // formato relativo de horas, mantém %s %d como o mesmo future: 'em %s', // exemplo: em 2 horas, %s será substituído por 2 horas diff --git a/src/constant.js b/src/constant.js index 2c9dd9aa0..5dbff8054 100644 --- a/src/constant.js +++ b/src/constant.js @@ -27,4 +27,4 @@ export const INVALID_DATE_STRING = 'Invalid Date' // regex export const REGEX_PARSE = /^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/ -export const REGEX_FORMAT = /\[.*?\]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g +export const REGEX_FORMAT = /\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g diff --git a/src/index.js b/src/index.js index 6ad4e5a1e..8c8841a81 100644 --- a/src/index.js +++ b/src/index.js @@ -315,10 +315,7 @@ class Dayjs { Z: zoneStr // 'ZZ' logic below } - return str.replace(C.REGEX_FORMAT, (match) => { - if (match.indexOf('[') > -1) return match.replace(/\[|\]/g, '') - return matches[match] || zoneStr.replace(':', '') // 'ZZ' - }) + return str.replace(C.REGEX_FORMAT, (match, $1) => $1 || matches[match] || zoneStr.replace(':', '')) // 'ZZ' } utcOffset() { diff --git a/src/locale/ca.js b/src/locale/ca.js index 5702a4d56..8586d6d2f 100644 --- a/src/locale/ca.js +++ b/src/locale/ca.js @@ -11,7 +11,10 @@ const locale = { L: 'DD/MM/YYYY', LL: 'D MMMM [de] YYYY', LLL: 'D MMMM [de] YYYY [a les] H:mm', - LLLL: 'dddd D MMMM [de] YYYY [a les] H:mm' + LLLL: 'dddd D MMMM [de] YYYY [a les] H:mm', + ll: 'D MMM YYYY', + lll: 'D MMM YYYY, H:mm', + llll: 'ddd D MMM YYYY, H:mm' }, relativeTime: { future: 'en %s', diff --git a/src/locale/cs.js b/src/locale/cs.js index 10e456e5f..0260aa00e 100644 --- a/src/locale/cs.js +++ b/src/locale/cs.js @@ -12,7 +12,8 @@ const locale = { L: 'DD.MM.YYYY', LL: 'D. MMMM YYYY', LLL: 'D. MMMM YYYY H:mm', - LLLL: 'dddd D. MMMM YYYY H:mm' + LLLL: 'dddd D. MMMM YYYY H:mm', + l: 'D. M. YYYY' }, relativeTime: { future: 'za %s', diff --git a/src/locale/fi.js b/src/locale/fi.js index e3661a3ec..f1f410898 100644 --- a/src/locale/fi.js +++ b/src/locale/fi.js @@ -32,6 +32,18 @@ const locale = { MM: '%d kuukautta', // for past tense y: 'vuosi', // for past tense yy: '%d vuotta' // for past tense + }, + formats: { + LT: 'HH.mm', + LTS: 'HH.mm.ss', + L: 'DD.MM.YYYY', + LL: 'Do MMMM[ta] YYYY', + LLL: 'Do MMMM[ta] YYYY, [klo] HH.mm', + LLLL: 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm', + l: 'D.M.YYYY', + ll: 'Do MMM YYYY', + lll: 'Do MMM YYYY, [klo] HH.mm', + llll: 'ddd, Do MMM YYYY, [klo] HH.mm' } } diff --git a/src/locale/he.js b/src/locale/he.js index 823f8327a..b9353760c 100644 --- a/src/locale/he.js +++ b/src/locale/he.js @@ -21,7 +21,19 @@ const locale = { y: 'שנה', yy: '%d שנים' }, - ordinal: n => n + ordinal: n => n, + format: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D [ב]MMMM YYYY', + LLL: 'D [ב]MMMM YYYY HH:mm', + LLLL: 'dddd, D [ב]MMMM YYYY HH:mm', + l: 'D/M/YYYY', + ll: 'D MMM YYYY', + lll: 'D MMM YYYY HH:mm', + llll: 'ddd, D MMM YYYY HH:mm' + } } dayjs.locale(locale, null, true) diff --git a/src/locale/ja.js b/src/locale/ja.js index a088ff666..72520a7cb 100644 --- a/src/locale/ja.js +++ b/src/locale/ja.js @@ -13,7 +13,11 @@ const locale = { L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', - LLLL: 'YYYY年M月D日 dddd HH:mm' + LLLL: 'YYYY年M月D日 dddd HH:mm', + l: 'YYYY/MM/DD', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日(ddd) HH:mm' }, relativeTime: { future: '%s後', diff --git a/src/locale/ko.js b/src/locale/ko.js index 0f89f59fc..04cbae8f1 100644 --- a/src/locale/ko.js +++ b/src/locale/ko.js @@ -12,7 +12,11 @@ const locale = { L: 'YYYY.MM.DD.', LL: 'YYYY년 MMMM D일', LLL: 'YYYY년 MMMM D일 A h:mm', - LLLL: 'YYYY년 MMMM D일 dddd A h:mm' + LLLL: 'YYYY년 MMMM D일 dddd A h:mm', + l: 'YYYY.MM.DD.', + ll: 'YYYY년 MMMM D일', + lll: 'YYYY년 MMMM D일 A h:mm', + llll: 'YYYY년 MMMM D일 dddd A h:mm' }, relativeTime: { future: '%s 후', diff --git a/src/locale/lt.js b/src/locale/lt.js index 0aa5abf44..9c2091852 100644 --- a/src/locale/lt.js +++ b/src/locale/lt.js @@ -20,6 +20,18 @@ const locale = { MM: '%d mėnesius', y: 'metus', yy: '%d metus' + }, + format: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'YYYY-MM-DD', + LL: 'YYYY [m.] MMMM D [d.]', + LLL: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', + LLLL: 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]', + l: 'YYYY-MM-DD', + ll: 'YYYY [m.] MMMM D [d.]', + lll: 'YYYY [m.] MMMM D [d.], HH:mm [val.]', + llll: 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]' } } diff --git a/src/locale/sv.js b/src/locale/sv.js index f4a713551..aa61d8f13 100644 --- a/src/locale/sv.js +++ b/src/locale/sv.js @@ -19,7 +19,9 @@ const locale = { L: 'YYYY-MM-DD', LL: 'D MMMM YYYY', LLL: 'D MMMM YYYY [kl.] HH:mm', - LLLL: 'dddd D MMMM YYYY [kl.] HH:mm' + LLLL: 'dddd D MMMM YYYY [kl.] HH:mm', + lll: 'D MMM YYYY HH:mm', + llll: 'ddd D MMM YYYY HH:mm' }, relativeTime: { future: 'om %s', diff --git a/src/locale/zh-cn.js b/src/locale/zh-cn.js index e3e754432..736944253 100644 --- a/src/locale/zh-cn.js +++ b/src/locale/zh-cn.js @@ -22,7 +22,11 @@ const locale = { L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日Ah点mm分', - LLLL: 'YYYY年M月D日ddddAh点mm分' + LLLL: 'YYYY年M月D日ddddAh点mm分', + l: 'YYYY/M/D', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s内', diff --git a/src/locale/zh-tw.js b/src/locale/zh-tw.js index 91a6e02e7..572b86c24 100644 --- a/src/locale/zh-tw.js +++ b/src/locale/zh-tw.js @@ -14,7 +14,11 @@ const locale = { L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', - LLLL: 'YYYY年M月D日dddd HH:mm' + LLLL: 'YYYY年M月D日dddd HH:mm', + l: 'YYYY/M/D', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s內', diff --git a/src/plugin/localizedFormat/index.js b/src/plugin/localizedFormat/index.js index 37d4db0ab..e3412dcfa 100644 --- a/src/plugin/localizedFormat/index.js +++ b/src/plugin/localizedFormat/index.js @@ -9,15 +9,19 @@ export default (o, c, d) => { L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', - LLLL: 'dddd, MMMM D, YYYY h:mm A' + LLLL: 'dddd, MMMM D, YYYY h:mm A', + l: 'M/D/YYYY', + ll: 'MMM D, YYYY', + lll: 'MMM D, YYYY h:mm A', + llll: 'ddd, MMM D, YYYY h:mm A' } d.en.formats = englishFormats proto.format = function (formatStr) { const locale = this.$locale() const formats = locale.formats || {} const str = formatStr || FORMAT_DEFAULT - const result = str.replace(/LTS|LT|L{1,4}/g, match => - formats[match] || englishFormats[match]) + const result = str.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => + a || formats[b] || englishFormats[b]) return oldFormat.call(this, result) } } diff --git a/test/display.test.js b/test/display.test.js index 603a6988b..1f8977586 100644 --- a/test/display.test.js +++ b/test/display.test.js @@ -138,7 +138,9 @@ it('Format Complex with other string - : / ', () => { }) it('Format Escaping characters', () => { - const string = '[Z] Z' + let string = '[Z] Z' + expect(dayjs().format(string)).toBe(moment().format(string)) + string = '[Z] Z [Z]' expect(dayjs().format(string)).toBe(moment().format(string)) }) diff --git a/test/locale/keys.test.js b/test/locale/keys.test.js index c22a86807..a01562e26 100644 --- a/test/locale/keys.test.js +++ b/test/locale/keys.test.js @@ -3,17 +3,17 @@ import path from 'path' import dayjs from '../../src' const localeDir = '../../src/locale' -const L = [] +const Locale = [] // load all locales from locale dir fs.readdirSync(path.join(__dirname, localeDir)) .forEach((file) => { // eslint-disable-next-line - L.push(require(path.join(__dirname, localeDir, file)).default) + Locale.push(require(path.join(__dirname, localeDir, file)).default) }) it('Locale keys', () => { - L.forEach((l) => { + Locale.forEach((locale) => { const { name, ordinal, @@ -25,7 +25,7 @@ it('Locale keys', () => { monthsShort, weekdaysMin, weekStart - } = l + } = locale expect(name).toEqual(expect.any(String)) expect(weekdays).toEqual(expect.any(Array)) @@ -44,7 +44,32 @@ it('Locale keys', () => { expect(dayjs().locale(name).$locale().name).toBe(name) if (formats) { - expect(Object.keys(formats).sort()).toEqual(['L', 'LL', 'LLL', 'LLLL', 'LT', 'LTS'].sort()) + const { + LT, + LTS, + L, + LL, + LLL, + LLLL, + l, + ll, + lll, + llll, + ...remainingFormats + } = formats + expect(formats).toEqual(expect.objectContaining({ + L: expect.any(String), + LL: expect.any(String), + LLL: expect.any(String), + LLLL: expect.any(String), + LT: expect.any(String), + LTS: expect.any(String) + })) + expect(Object.keys(remainingFormats).length).toEqual(0) + if (l) expect(l).toEqual(expect.any(String)) + if (ll) expect(ll).toEqual(expect.any(String)) + if (lll) expect(lll).toEqual(expect.any(String)) + if (llll) expect(llll).toEqual(expect.any(String)) } if (relativeTime) { expect(Object.keys(relativeTime).sort()).toEqual(['d', 'dd', 'future', 'h', 'hh', 'm', 'mm', 'M', 'MM', diff --git a/test/plugin/localizableFormat.test.js b/test/plugin/localizableFormat.test.js index 5e6b3055d..dc6348125 100644 --- a/test/plugin/localizableFormat.test.js +++ b/test/plugin/localizableFormat.test.js @@ -18,14 +18,25 @@ afterEach(() => { it('Declares English localized formats', () => { expect(dayjs.en).toBeDefined() expect(dayjs.en.formats).toBeDefined(); - ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => + ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL', 'l', 'll', 'lll', 'llll'].forEach(option => expect(dayjs.en.formats[option]).toBeDefined()) }) +it('Should not interpolate characters inside square brackets', () => { + const date = new Date(0) + const actualDate = dayjs(date) + const expectedDate = moment(date) + + expect(actualDate.format('[l]')).toBe('l') + expect(actualDate.format('YYYY [l] YYYY')).toBe('1970 l 1970') + expect(actualDate.format('l [l] l')).toBe('1/1/1970 l 1/1/1970') + expect(actualDate.format('[L LL LLL LLLL]')).toBe(expectedDate.format('[L LL LLL LLLL]')) +}) + it('Recognizes localized format options', () => { const { formats } = dayjs.en const date = dayjs(); - ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => + ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL', 'l', 'll', 'lll', 'llll'].forEach(option => expect(date.format(option)).toBe(date.format(formats[option]))) }) @@ -33,7 +44,7 @@ it('Uses correct English formats', () => { const date = new Date() const actualDate = dayjs(date) const expectedDate = moment(date); - ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL'].forEach(option => + ['LT', 'LTS', 'L', 'LL', 'LLL', 'LLLL', 'l', 'll', 'lll', 'llll'].forEach(option => expect(actualDate.format(option)).toBe(expectedDate.format(option))) }) From 222592da90b36fbb6d5e7b5acb2890aea51c0d28 Mon Sep 17 00:00:00 2001 From: iamkun Date: Mon, 1 Apr 2019 19:11:38 +0800 Subject: [PATCH 14/17] test: Update test to keep locale name and file name the same --- test/locale/keys.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/locale/keys.test.js b/test/locale/keys.test.js index a01562e26..71027d20d 100644 --- a/test/locale/keys.test.js +++ b/test/locale/keys.test.js @@ -8,8 +8,11 @@ const Locale = [] // load all locales from locale dir fs.readdirSync(path.join(__dirname, localeDir)) .forEach((file) => { - // eslint-disable-next-line - Locale.push(require(path.join(__dirname, localeDir, file)).default) + Locale.push({ + name: file, + // eslint-disable-next-line import/no-dynamic-require, global-require + content: require(path.join(__dirname, localeDir, file)).default + }) }) it('Locale keys', () => { @@ -25,8 +28,9 @@ it('Locale keys', () => { monthsShort, weekdaysMin, weekStart - } = locale - expect(name).toEqual(expect.any(String)) + } = locale.content + + expect(name).toEqual(locale.name.replace('.js', '')) expect(weekdays).toEqual(expect.any(Array)) if (weekdaysShort) expect(weekdaysShort).toEqual(expect.any(Array)) From c30b715e61f13dfc31e15cb5f9730eb012a7fcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quent=C3=AD?= <33203663+Quenty31@users.noreply.github.com> Date: Tue, 2 Apr 2019 04:33:50 +0200 Subject: [PATCH 15/17] fix: Add Occitan (oc-lnc) locale file (#551) --- src/locale/oc-lnc.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/locale/oc-lnc.js diff --git a/src/locale/oc-lnc.js b/src/locale/oc-lnc.js new file mode 100644 index 000000000..8e7ec7146 --- /dev/null +++ b/src/locale/oc-lnc.js @@ -0,0 +1,38 @@ +import dayjs from 'dayjs' + +const locale = { + name: 'oc-lnc', + weekdays: 'Dimenge_Diluns_Dimars_Dimècres_Dijòus_Divendres_Dissabte'.split('_'), + weekdaysShort: 'Dg_Dl_Dm_Dc_Dj_Dv_Ds'.split('_'), + months: 'Genièr_Febrièr_Març_Abrial_Mai_Junh_Julhet_Agost_Setembre_Octòbre_Novembre_Decembre'.split('_'), + monthsShort: 'Gen_Feb_Març_Abr_Mai_Junh_Julh_Ago_Set_Oct_Nov_Dec'.split('_'), + weekStart: 1, + formats: { + LT: 'H:mm', + LTS: 'H:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D MMMM [de] YYYY', + LLL: 'D MMMM [de] YYYY [a] H:mm', + LLLL: 'dddd D MMMM [de] YYYY [a] H:mm' + }, + relativeTime: { + future: 'en %s', + past: 'fa %s', + s: 'unas segondas', + m: 'una minuta', + mm: '%d minutas', + h: 'una ora', + hh: '%d oras', + d: 'un jorn', + dd: '%d jorns', + M: 'un mes', + MM: '%d meses', + y: 'un an', + yy: '%d ans' + }, + ordinal: n => `${n}º` +} + +dayjs.locale(locale, null, true) + +export default locale From b663444c95edc32f64050d6139c5f9260918cd7f Mon Sep 17 00:00:00 2001 From: iamkun Date: Tue, 2 Apr 2019 10:41:48 +0800 Subject: [PATCH 16/17] docs: Update zh-cn doc --- docs/zh-cn/Plugin.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 89caccc6b..6b82e2c3c 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -126,14 +126,18 @@ dayjs().format('L LT') 扩展的模版列表: -| 模版 | 格式 | 输出 | -| ------ | ------------------------- | --------------------------------- | -| `LT` | h:mm A | 8:02 PM | -| `LTS` | h:mm:ss A | 8:02:18 PM | -| `L` | MM/DD/YYYY | 08/16/2018 | -| `LL` | MMMM D, YYYY | August 16, 2018 | -| `LLL` | MMMM D, YYYY h:mm A | August 16, 2018 8:02 PM | -| `LLLL` | dddd, MMMM D, YYYY h:mm A | Thursday, August 16, 2018 8:02 PM | +| 模版 | 格式 | 输出 | +| ------ | --------------------------------- | --------------------------------------- | +| `LT` | HH:mm | 8:02 | +| `LTS` | HH:mm:ss | 15:25:50 | +| `L` | YYYY/MM/DD | 2010/02/14 | +| `LL` | YYYY 年 M 月 D 日 | 2010 年 2 月 14 日 | +| `LLL` | YYYY 年 M 月 D 日 Ah 点 mm 分 | 2010 年 2 月 14 日下午 3 点 25 分 | +| `LLLL` | YYYY 年 M 月 D 日 ddddAh 点 mm 分 | 2010 年 2 月 14 日星期日下午 3 点 25 分 | +| `l` | YYYY/M/D | 2010/2/14 | +| `ll` | YYYY 年 M 月 D 日 | 2010 年 2 月 14 日 | +| `lll` | YYYY 年 M 月 D 日 HH:mm | 2010 年 2 月 14 日 15:25 | +| `llll` | YYYY 年 M 月 D 日 dddd HH:mm | 2010 年 2 月 14 日星期日 15:25 | ### RelativeTime From 6a297b703f14981fb2458cc2521637750a0f1f2a Mon Sep 17 00:00:00 2001 From: phobal Date: Tue, 2 Apr 2019 12:10:24 +0800 Subject: [PATCH 17/17] chore: calendar plugin get config from locale file (#552) --- src/plugin/calendar/index.js | 2 +- test/plugin/calendar.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugin/calendar/index.js b/src/plugin/calendar/index.js index 87db1894a..e62e1fa38 100644 --- a/src/plugin/calendar/index.js +++ b/src/plugin/calendar/index.js @@ -11,7 +11,7 @@ export default (o, c, d) => { } const proto = c.prototype proto.calendar = function (referenceTime, formats) { - const format = formats || calendarFormat + const format = formats || this.$locale().calendar || calendarFormat const referenceStartOfDay = d(referenceTime || undefined).startOf('d') const diff = this.diff(referenceStartOfDay, 'd', true) const sameElse = 'sameElse' diff --git a/test/plugin/calendar.test.js b/test/plugin/calendar.test.js index 24dec0f7e..31391ad06 100644 --- a/test/plugin/calendar.test.js +++ b/test/plugin/calendar.test.js @@ -2,6 +2,7 @@ import MockDate from 'mockdate' import moment from 'moment' import dayjs from '../../src' import calendar from '../../src/plugin/calendar' +import zhCn from '../../src/locale/zh-cn' dayjs.extend(calendar) @@ -79,3 +80,18 @@ it('Custom format', () => { expect(dayjs(now).calendar(nextDayWithoutFormat, format)) .toEqual(moment(now).calendar(nextDayWithoutFormat, format)) }) + +it('set global calendar in locale file', () => { + const now = '2019-04-03T14:21:22.000Z' + zhCn.calendar = { + sameDay: '[今天]HH:mm', + nextDay: '[明天]HH:mm', + nextWeek: '[下]ddddHH:mm', + lastDay: '[昨天]HH:mm', + lastWeek: '[上]ddddHH:mm', + sameElse: 'YYYY/MM/DD' + } + dayjs.locale(zhCn) + expect(dayjs(now).calendar()) + .toEqual(moment(now).locale('zh-cn').calendar()) +})