Skip to content

Commit

Permalink
Merge pull request #476 from iamkun/dev
Browse files Browse the repository at this point in the history
D2M
  • Loading branch information
iamkun committed Feb 5, 2019
2 parents 209a5f2 + ca49e7c commit 7726b21
Show file tree
Hide file tree
Showing 44 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/en/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ dayjs().subtract(7, "year");
Returns a cloned `Dayjs` set to the start of the specified unit of time.

```js
dayjs().startOf("week");
dayjs().startOf("week"); // Depends on `weekStart` in locale
```

### End of Time `.endOf(unit: string)`
Expand Down
2 changes: 1 addition & 1 deletion docs/es-es/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ dayjs().subtract(7, "year");
Devuelve un nuevo objeto `Dayjs`, resultante de ajustar el actual al principio de la unidad de tiempo indicada.

```js
dayjs().startOf("week");
dayjs().startOf("week"); // Depends on `weekStart` in locale
```

### Fin de `.endOf(unit: string)`
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Returns a new `Dayjs` object by by setting it to the start of a unit of time.

```js
dayjs().startOf((unit: String));
dayjs().startOf('year');
dayjs().startOf('week'); // Depends on `weekStart` in locale
```

#### End of Time
Expand Down
2 changes: 1 addition & 1 deletion docs/ko/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ dayjs().subtract(7, 'year');
특정 시간 단위의 시작 시점에 대한 시간을 `Dayjs` 오브젝트 복제본으로 반환합니다.

```js
dayjs().startOf('week');
dayjs().startOf('week'); // Depends on `weekStart` in locale
```

### End of Time `.endOf(unit: string)`
Expand Down
2 changes: 1 addition & 1 deletion docs/pt-br/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ dayjs().subtract(7, 'year');
Retorna um objeto `Dayjs` clonado definido com o começo da unidade de tempo especificada.

```js
dayjs().startOf('week');
dayjs().startOf('week'); // Depends on `weekStart` in locale
```

### Fim do Tempo `.endOf(unit: string)`
Expand Down
2 changes: 1 addition & 1 deletion docs/zh-cn/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dayjs().subtract(7, 'year');
返回当前时间的开头时间的 `Dayjs()` 对象,如月份的第一天。
```js
dayjs().startOf(unit : String);
dayjs().startOf('year');
dayjs().startOf('week'); // 取决于 locale 文件里 `weekStart` 的值
```
#### 末尾时间
返回当前时间的末尾时间的 `Dayjs()` 对象,如月份的最后一天。
Expand Down
3 changes: 1 addition & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export = dayjs;
declare function dayjs (config?: dayjs.ConfigType, option?: dayjs.OptionType): dayjs.Dayjs
export default dayjs

declare namespace dayjs {
export type ConfigType = string | number | Date | Dayjs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "index.d.ts",
"module": "./src/index.js",
"scripts": {
"test": "jest && TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && npm run test-tz",
"test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && npm run test-tz && jest",
"test-tz": "jest test/timezone.test --coverage=false",
"lint": "./node_modules/.bin/eslint src/* test/* build/*",
"build": "cross-env BABEL_ENV=build node build && npm run size",
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ class Dayjs {
return isStartOf ? instanceFactory(1, this.$M) :
instanceFactory(0, this.$M + 1)
case C.W: {
const l = this.$locale()
const weekStart = l && l.weekStart === 1 ? 1 : 0
const weekStart = this.$locale().weekStart || 0
return isStartOf ? instanceFactory(this.$D - (this.$W - weekStart), this.$M) :
instanceFactory(this.$D + (6 - (this.$W - weekStart)), this.$M)
}
Expand Down
1 change: 1 addition & 0 deletions src/locale/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'bg',
weekdays: 'Неделя_Понеделник_Вторник_Сряда_Четвъртък_Петък_Събота'.split('_'),
months: 'Януари_Февруари_Март_Април_Май_Юни_Юли_Август_Септември_Октомври_Ноември_Декември'.split('_'),
weekStart: 1,
ordinal: n => `${n}.`,
formats: {
LT: 'H:mm',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'ca',
weekdays: 'Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte'.split('_'),
months: 'Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'cs',
weekdays: 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
months: 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'),
weekStart: 1,
ordinal: n => `${n}.`,
formats: {
LT: 'H:mm',
Expand Down
1 change: 1 addition & 0 deletions src/locale/da.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'da',
weekdays: 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
months: 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
weekStart: 1,
ordinal: n => `${n}.`,
formats: {
LT: 'HH:mm',
Expand Down
1 change: 1 addition & 0 deletions src/locale/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const locale = {
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan_Feb_März_Apr_Mai_Juni_Juli_Aug_Sept_Okt_Nov_Dez'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
formats: {
LTS: 'HH:mm:ss',
LT: 'HH:mm',
Expand Down
1 change: 1 addition & 0 deletions src/locale/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const locale = {
months: 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
monthsShort: 'Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ'.split('_'),
ordinal: n => n,
weekStart: 1,
relativeTime: {
future: 'σε %s',
past: 'πριν %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/es-do.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'),
weekStart: 1,
relativeTime: {
future: 'en %s',
past: 'hace %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/et.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locale = {
months: 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'), // Note month names are not capitalized in Estonian
monthsShort: 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
/*
* This relativeTime is currently configured for having proper past
* tense forms since Estonian needs a separate version for future tense
Expand Down
1 change: 1 addition & 0 deletions src/locale/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locale = {
months: 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'), // Note month names are not capitalized in Finnish
monthsShort: 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'), // There is no short form of months in Finnish so just use the regular long form always
ordinal: n => `${n}.`,
weekStart: 1,
/*
* This relativeTime is currently configured for having proper past
* tense forms since Finnish needs a separate version for future tense
Expand Down
1 change: 1 addition & 0 deletions src/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const locale = {
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('_'),
monthsShort: 'janv_févr_mars_avril_mai_juin_juil_août_sept_oct_nov_déc'.split('_'),
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/hr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'hr',
weekdays: 'Nedjelja_Ponedjeljak_Utorak_Srijeda_Četvrtak_Petak_Subota'.split('_'),
months: 'Siječanj_Veljača_Ožujak_Travanj_Svibanj_Lipanj_Srpanj_Kolovoz_Rujan_Listopad_Studeni_Prosinac'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locale = {
months: 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
monthsShort: 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
relativeTime: {
future: '%s múlva',
past: '%s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'id',
weekdays: 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
weekStart: 1,
formats: {
LT: 'HH.mm',
LTS: 'HH.mm.ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const locale = {
weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'),
weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'),
months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
weekStart: 1,
monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
formats: {
LT: 'HH:mm',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ka.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'ka',
weekdays: 'კვირა_ორშაბათი_სამშაბათი_გარემო_ხუთშაბათი_პარასკევი_შაბათს'.split('_'),
months: 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
weekStart: 1,
formats: {
LT: 'h:mm A',
LTS: 'h:mm:ss A',
Expand Down
1 change: 1 addition & 0 deletions src/locale/kk.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
months: 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
monthsShort: 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
weekStart: 1,
relativeTime: {
future: '%s ішінде',
past: '%s бұрын',
Expand Down
1 change: 1 addition & 0 deletions src/locale/lt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const locale = {
weekdays: 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_'),
months: 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
relativeTime: {
future: 'už %s',
past: 'prieš %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/nb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const locale = {
weekdays: 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
months: 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const locale = {
weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/nn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locale = {
months: 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
monthsShort: 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
relativeTime: {
future: 'om %s',
past: 'for %s sidan',
Expand Down
1 change: 1 addition & 0 deletions src/locale/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
months: 'Styczeń_Luty_Marzec_Kwiecień_Maj_Czerwiec_Lipiec_Sierpień_Wrzesień_Październik_Listopad_Grudzień'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
relativeTime: {
future: 'za %s',
past: 'po %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const locale = {
weekdays: 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
months: 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
ordinal: n => `${n}º`,
weekStart: 1,
relativeTime: {
future: 'em %s',
past: 'há %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'ro',
weekdays: 'Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă'.split('_'),
months: 'Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
months: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
monthsShort: 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'sk',
weekdays: 'Nedeľa_Pondelok_Utorok_Streda_Štvrtok_Piatok_Sobota'.split('_'),
months: 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'),
weekStart: 1,
relativeTime: {
future: 'o %s',
past: 'pred %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/sr-cyrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'sr-cyrl',
weekdays: 'Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота'.split('_'),
months: 'Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар'.split('_'),
weekStart: 1,
relativeTime: {
future: 'за %s',
past: 'пре %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/sr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'sr',
weekdays: 'Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota'.split('_'),
months: 'Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar'.split('_'),
weekStart: 1,
relativeTime: {
future: 'za %s',
past: 'pre %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'sv',
weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
weekStart: 1,
ordinal: (n) => {
const b = n % 10
const o = (b === 1) || (b === 2) ? 'a' : 'e'
Expand Down
1 change: 1 addition & 0 deletions src/locale/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const locale = {
name: 'tr',
weekdays: 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
months: 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
1 change: 1 addition & 0 deletions src/locale/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
months: 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
monthsShort: 'сiч_лют_бер_квiт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
weekStart: 1,
relativeTime: {
future: 'через %s',
past: '%s назад',
Expand Down
1 change: 1 addition & 0 deletions src/locale/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locale = {
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
ordinal: n => `${n}日`,
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
4 changes: 3 additions & 1 deletion test/locale/keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ it('Locale keys', () => {
relativeTime,
weekdaysShort,
monthsShort,
weekdaysMin
weekdaysMin,
weekStart
} = l
expect(name).toEqual(expect.any(String))
expect(weekdays).toEqual(expect.any(Array))

if (weekdaysShort) expect(weekdaysShort).toEqual(expect.any(Array))
if (monthsShort) expect(monthsShort).toEqual(expect.any(Array))
if (weekdaysMin) expect(weekdaysMin).toEqual(expect.any(Array))
if (weekStart) expect(weekStart).toEqual(expect.any(Number))

expect(months).toEqual(expect.any(Array))
// function pass date return string or number or null
Expand Down
10 changes: 10 additions & 0 deletions test/manipulate.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import moment from 'moment'
import MockDate from 'mockdate'
import dayjs from '../src'
import '../src/locale/zh-cn'
import '../src/locale/ar'

beforeEach(() => {
MockDate.set(new Date())
Expand Down Expand Up @@ -28,6 +30,14 @@ describe('StartOf EndOf', () => {
expect(dayjs().startOf('otherString').valueOf()).toBe(moment().startOf('otherString').valueOf())
expect(dayjs().endOf('otherString').valueOf()).toBe(moment().endOf('otherString').valueOf())
})

it('StartOf week with locale', () => {
const testArr = ['zh-cn']
testArr.forEach((l) => {
expect(dayjs().locale(l).startOf('week').date()).toBe(moment().locale(l).startOf('week').date())
expect(dayjs().locale(l).endOf('week').date()).toBe(moment().locale(l).endOf('week').date())
})
})
})


Expand Down
1 change: 1 addition & 0 deletions test/plugin/weekOfYear.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ it('Week of year', () => {
expect(dayjs().weeks(week).week()).toBe(moment().weeks(week).week())
expect(dayjs().weeks(-week).week()).toBe(moment().weeks(-week).week())
expect(dayjs().weeks(55).week()).toBe(moment().weeks(55).week())
expect(dayjs().weeks()).toBe(moment().weeks())
})

0 comments on commit 7726b21

Please sign in to comment.