@@ -19,6 +19,10 @@ import {
19
19
} from "../src/date_utils" ;
20
20
import setMinutes from "date-fns/setMinutes" ;
21
21
import setHours from "date-fns/setHours" ;
22
+ import ptBR from "date-fns/locale/pt-BR" ;
23
+ import { registerLocale } from "../src/date_utils" ;
24
+
25
+ registerLocale ( "pt-BR" , ptBR ) ;
22
26
23
27
describe ( "date_utils" , function ( ) {
24
28
describe ( "newDate" , function ( ) {
@@ -393,6 +397,25 @@ describe("date_utils", function() {
393
397
394
398
expect ( parseDate ( value , dateFormat , null , false ) ) . to . not . be . null ;
395
399
} ) ;
400
+
401
+ it ( "should parse date based on locale" , ( ) => {
402
+ const value = "26/05/1995" ;
403
+ const dateFormat = "P" ;
404
+
405
+ const expected = new Date ( "05/26/1995" ) ;
406
+ const actual = parseDate ( value , dateFormat , "pt-BR" , false ) ;
407
+
408
+ assert ( isEqual ( actual , expected ) ) ;
409
+ } ) ;
410
+
411
+ it ( "should not parse date based on locale without a given locale" , ( ) => {
412
+ const value = "26/05/1995" ;
413
+ const dateFormat = "P" ;
414
+
415
+ const actual = parseDate ( value , dateFormat , null , false ) ;
416
+
417
+ expect ( actual ) . to . be . null ;
418
+ } ) ;
396
419
} ) ;
397
420
398
421
describe ( "isMonthinRange" , ( ) => {
0 commit comments