@@ -482,7 +482,12 @@ describe('dates', function() {
482482 describe ( 'formatDate' , function ( ) {
483483 function assertFormatRounds ( ms , calendar , results ) {
484484 [ '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+ } ) )
486491 . toBe ( results [ i ] , calendar ) ;
487492 } ) ;
488493 }
@@ -598,17 +603,23 @@ describe('dates', function() {
598603 } ) ;
599604
600605 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 ) )
606617 . toBe ( '00:00:00\nKoi 23, 1686' ) ;
607618
608619 // because the decimal point is explicitly part of the format
609620 // 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' ) ;
612623 } ) ;
613624
614625 } ) ;
0 commit comments