@@ -482,7 +482,12 @@ describe('dates', function() {
482
482
describe ( 'formatDate' , function ( ) {
483
483
function assertFormatRounds ( ms , calendar , results ) {
484
484
[ 'y' , 'm' , 'd' , 'M' , 'S' , 1 , 2 , 3 , 4 ] . forEach ( function ( tr , i ) {
485
- expect ( Lib . formatDate ( ms , '' , tr , utcFormat , calendar ) )
485
+ expect ( Lib . formatDate ( ms , '' , tr , utcFormat , calendar , {
486
+ year : '%Y' ,
487
+ month : '%b %Y' ,
488
+ dayMonth : '%b %-d' ,
489
+ dayMonthYear : '%b %-d, %Y'
490
+ } ) )
486
491
. toBe ( results [ i ] , calendar ) ;
487
492
} ) ;
488
493
}
@@ -598,17 +603,23 @@ describe('dates', function() {
598
603
} ) ;
599
604
600
605
it ( 'should remove extra fractional second zeros' , function ( ) {
601
- expect ( Lib . formatDate ( 0.1 , '' , 4 , utcFormat ) ) . toBe ( '00:00:00.0001\nJan 1, 1970' ) ;
602
- expect ( Lib . formatDate ( 0.1 , '' , 3 , utcFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
603
- expect ( Lib . formatDate ( 0.1 , '' , 0 , utcFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
604
- expect ( Lib . formatDate ( 0.1 , '' , 'S' , utcFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
605
- expect ( Lib . formatDate ( 0.1 , '' , 3 , utcFormat , 'coptic' ) )
606
+ var extraFormat = {
607
+ year : '%Y' ,
608
+ month : '%b %Y' ,
609
+ dayMonth : '%b %-d' ,
610
+ dayMonthYear : '%b %-d, %Y'
611
+ } ;
612
+ expect ( Lib . formatDate ( 0.1 , '' , 4 , utcFormat , null , extraFormat ) ) . toBe ( '00:00:00.0001\nJan 1, 1970' ) ;
613
+ expect ( Lib . formatDate ( 0.1 , '' , 3 , utcFormat , null , extraFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
614
+ expect ( Lib . formatDate ( 0.1 , '' , 0 , utcFormat , null , extraFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
615
+ expect ( Lib . formatDate ( 0.1 , '' , 'S' , utcFormat , null , extraFormat ) ) . toBe ( '00:00:00\nJan 1, 1970' ) ;
616
+ expect ( Lib . formatDate ( 0.1 , '' , 3 , utcFormat , 'coptic' , extraFormat ) )
606
617
. toBe ( '00:00:00\nKoi 23, 1686' ) ;
607
618
608
619
// because the decimal point is explicitly part of the format
609
620
// string here, we can't remove it OR the very first zero after it.
610
- expect ( Lib . formatDate ( 0.1 , '%S.%f' , null , utcFormat ) ) . toBe ( '00.0001' ) ;
611
- expect ( Lib . formatDate ( 0.1 , '%S.%3f' , null , utcFormat ) ) . toBe ( '00.0' ) ;
621
+ expect ( Lib . formatDate ( 0.1 , '%S.%f' , null , utcFormat , null , extraFormat ) ) . toBe ( '00.0001' ) ;
622
+ expect ( Lib . formatDate ( 0.1 , '%S.%3f' , null , utcFormat , null , extraFormat ) ) . toBe ( '00.0' ) ;
612
623
} ) ;
613
624
614
625
} ) ;
0 commit comments