@@ -3,6 +3,7 @@ import moment from 'moment'
3
3
import dayjs from '../../src'
4
4
import customParseFormat from '../../src/plugin/customParseFormat'
5
5
import uk from '../../src/locale/uk'
6
+ import '../../src/locale/zh-cn'
6
7
7
8
dayjs . extend ( customParseFormat )
8
9
@@ -169,3 +170,19 @@ it('correctly parse month from string after changing locale globally', () => {
169
170
moment . locale ( momentLocale )
170
171
}
171
172
} )
173
+
174
+ it ( 'correctly parse ordinal' , ( ) => {
175
+ const input = '7th March 2019'
176
+ const input2 = '17th March 2019'
177
+ const inputFalse = '7st March 2019'
178
+ const inputZHCN = '7日 三月 2019'
179
+ const format = 'Do MMMM YYYY'
180
+ expect ( dayjs ( input , format ) . valueOf ( ) )
181
+ . toBe ( moment ( input , format ) . valueOf ( ) )
182
+ expect ( dayjs ( input2 , format ) . valueOf ( ) )
183
+ . toBe ( moment ( input2 , format ) . valueOf ( ) )
184
+ expect ( dayjs ( inputFalse , format ) . valueOf ( ) )
185
+ . toBe ( moment ( inputFalse , format ) . valueOf ( ) )
186
+ expect ( dayjs ( inputZHCN , format , 'zh-cn' ) . valueOf ( ) )
187
+ . toBe ( moment ( inputZHCN , format , 'zh-cn' ) . valueOf ( ) )
188
+ } )
0 commit comments