nl_tokens: Date formatting helpers
pl_tokens: function formatDate ( date , format , <mask> , localeCode ) { var adu , loc = getLocalization ( localeCode ) , caps = regexp ( / ^[A-Z] / ) , value , shortcut ; if ( ! date . isValid ( ) ) { return 'Invalid Date' ; } else if ( Date [ format ] ) { format = Date [ format ] ; } else if ( isFunction ( format ) ) { adu = getAdjustedUnitWithMonthFallback ( date ) ; format = format . apply ( date , adu . concat ( loc ) ) ; } if ( ! format && relative ) { adu = adu || getAdjustedUnitWithMonthFallback ( date ) ; // Adjust up if time is in ms, as this doesn't // look very good for a standard relative date. if ( adu [ 1 ] === 0 ) { adu [ 1 ] = 1 ; adu [ 0 ] = 1 ; } return loc . getRelativeFormat ( adu ) ; } format = format || 'long' ; format = loc [ format ] || format ; DateOutputFormats . forEach ( function ( dof ) { format = format . replace ( regexp ( '\\{(' + dof . token + ')(\\d)?\\}' , dof . word ? 'i' : '' ) , function ( m , t , d ) { var val = dof . format ( date , loc , d || 1 , t ) , l = t . length , one = t . match ( / ^(.)\1+$ / ) ; if ( dof . word ) { if ( l === 3 ) val = val . slice ( 0 , 3 ) ; if ( one || t . match ( caps ) ) val = simpleCapitalize ( val ) ; } else if ( one && ! dof . text ) { val = ( isNumber ( val ) ? padNumber ( val , l ) : val . toString ( ) ) . slice ( - l ) ; } return val ; } ) ; } ) ; return format ; }