File tree 3 files changed +116
-0
lines changed
3 files changed +116
-0
lines changed Original file line number Diff line number Diff line change
1
+ // English (India) [en-in]
2
+ import dayjs from 'dayjs'
3
+
4
+ const locale = {
5
+ name : 'en-in' ,
6
+ weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday' . split ( '_' ) ,
7
+ weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat' . split ( '_' ) ,
8
+ weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa' . split ( '_' ) ,
9
+ months : 'January_February_March_April_May_June_July_August_September_October_November_December' . split ( '_' ) ,
10
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec' . split ( '_' ) ,
11
+ weekStart : 1 ,
12
+ yearStart : 4 ,
13
+ relativeTime : {
14
+ future : 'in %s' ,
15
+ past : '%s ago' ,
16
+ s : 'a few seconds' ,
17
+ m : 'a minute' ,
18
+ mm : '%d minutes' ,
19
+ h : 'an hour' ,
20
+ hh : '%d hours' ,
21
+ d : 'a day' ,
22
+ dd : '%d days' ,
23
+ M : 'a month' ,
24
+ MM : '%d months' ,
25
+ y : 'a year' ,
26
+ yy : '%d years'
27
+ } ,
28
+ formats : {
29
+ LT : 'HH:mm' ,
30
+ LTS : 'HH:mm:ss' ,
31
+ L : 'DD/MM/YYYY' ,
32
+ LL : 'D MMMM YYYY' ,
33
+ LLL : 'D MMMM YYYY HH:mm' ,
34
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
35
+ } ,
36
+ ordinal : ( n ) => {
37
+ const s = [ 'th' , 'st' , 'nd' , 'rd' ]
38
+ const v = n % 100
39
+ return `[${ n } ${ ( s [ ( v - 20 ) % 10 ] || s [ v ] || s [ 0 ] ) } ]`
40
+ }
41
+ }
42
+
43
+ dayjs . locale ( locale , null , true )
44
+
45
+ export default locale
46
+
Original file line number Diff line number Diff line change
1
+ // English (Trinidad & Tobago) [en-tt]
2
+ import dayjs from 'dayjs'
3
+
4
+ const locale = {
5
+ name : 'en-tt' ,
6
+ weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday' . split ( '_' ) ,
7
+ weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat' . split ( '_' ) ,
8
+ weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa' . split ( '_' ) ,
9
+ months : 'January_February_March_April_May_June_July_August_September_October_November_December' . split ( '_' ) ,
10
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec' . split ( '_' ) ,
11
+ weekStart : 1 ,
12
+ yearStart : 4 ,
13
+ relativeTime : {
14
+ future : 'in %s' ,
15
+ past : '%s ago' ,
16
+ s : 'a few seconds' ,
17
+ m : 'a minute' ,
18
+ mm : '%d minutes' ,
19
+ h : 'an hour' ,
20
+ hh : '%d hours' ,
21
+ d : 'a day' ,
22
+ dd : '%d days' ,
23
+ M : 'a month' ,
24
+ MM : '%d months' ,
25
+ y : 'a year' ,
26
+ yy : '%d years'
27
+ } ,
28
+ formats : {
29
+ LT : 'HH:mm' ,
30
+ LTS : 'HH:mm:ss' ,
31
+ L : 'DD/MM/YYYY' ,
32
+ LL : 'D MMMM YYYY' ,
33
+ LLL : 'D MMMM YYYY HH:mm' ,
34
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
35
+ } ,
36
+ ordinal : ( n ) => {
37
+ const s = [ 'th' , 'st' , 'nd' , 'rd' ]
38
+ const v = n % 100
39
+ return `[${ n } ${ ( s [ ( v - 20 ) % 10 ] || s [ v ] || s [ 0 ] ) } ]`
40
+ }
41
+ }
42
+
43
+ dayjs . locale ( locale , null , true )
44
+
45
+ export default locale
46
+
Original file line number Diff line number Diff line change
1
+ import dayjs from '../../src'
2
+ import '../../src/locale/en'
3
+ import '../../src/locale/en-gb'
4
+ import '../../src/locale/en-in'
5
+ import '../../src/locale/en-tt'
6
+ import localizedFormat from '../../src/plugin/localizedFormat'
7
+
8
+ dayjs . extend ( localizedFormat )
9
+
10
+ const locales = [
11
+ { locale : 'en' , expectedDate : '12/25/2019' } ,
12
+ { locale : 'en-gb' , expectedDate : '25/12/2019' } ,
13
+ { locale : 'en-in' , expectedDate : '25/12/2019' } ,
14
+ { locale : 'en-tt' , expectedDate : '25/12/2019' }
15
+ ]
16
+
17
+ describe ( 'English date formats' , ( ) => {
18
+ locales . forEach ( ( locale ) => {
19
+ it ( `should correctly format date with locale - ${ locale . locale } ` , ( ) => {
20
+ const dayjsWithLocale = dayjs ( '2019-12-25' ) . locale ( locale . locale )
21
+ expect ( dayjsWithLocale . format ( 'L' ) ) . toEqual ( locale . expectedDate )
22
+ } )
23
+ } )
24
+ } )
You can’t perform that action at this time.
0 commit comments