@@ -2,7 +2,7 @@ const DAY_TIMESTAMP = 60 * 60 * 24 * 1000
22const HOUR_TIMESTAMP = 60 * 60 * 1000
33const MINUTE_TIMESTAMP = 60 * 1000
44
5- function formatType ( type , format , value , attributes ) {
5+ function formatType ( type , format , value , regExpAttributes ) {
66 const regExpMap = {
77 year : '(Y+)' ,
88 month : '(M+)' ,
@@ -14,7 +14,7 @@ function formatType(type, format, value, attributes) {
1414 millisecond : '(S)'
1515 }
1616
17- if ( new RegExp ( regExpMap [ type ] , attributes ) . test ( format ) ) {
17+ if ( new RegExp ( regExpMap [ type ] , regExpAttributes ) . test ( format ) ) {
1818 const replaceStr = type === 'year'
1919 ? value . toString ( ) . substr ( 4 - RegExp . $1 . length )
2020 : ( RegExp . $1 . length === 1 ) ? value : pad ( value )
@@ -28,7 +28,7 @@ function pad(value) {
2828 return ( '00' + value ) . substr ( ( '' + value ) . length )
2929}
3030
31- function formatDate ( date , format ) {
31+ function formatDate ( date , format , regExpAttributes ) {
3232 const map = {
3333 year : date . getFullYear ( ) ,
3434 month : date . getMonth ( ) + 1 ,
@@ -41,7 +41,7 @@ function formatDate(date, format) {
4141 }
4242
4343 for ( const key in map ) {
44- format = formatType ( key , format , map [ key ] )
44+ format = formatType ( key , format , map [ key ] , regExpAttributes )
4545 }
4646
4747 return format
0 commit comments