11'use strict' ;
22
3- define ( [ 'require' , 'jquery' , 'lodash' , 'src/util/api' , 'src/util/util' ] , function ( require , $ , _ , API , Util ) {
3+ define ( [ 'require' , 'jquery' , 'lodash' , 'src/util/api' , 'src/util/util' , 'moment' ] , function ( require , $ , _ , API , Util , moment ) {
44
55 var functions = { } ;
66
@@ -73,6 +73,16 @@ define(['require', 'jquery', 'lodash', 'src/util/api', 'src/util/util'], functio
7373 $element . html ( result ) ;
7474 } ;
7575
76+ function checkDate ( options ) {
77+ return options . hasOwnProperty ( 'dateFormat' ) ;
78+ }
79+
80+ function toDate ( value , options ) {
81+ if ( options . dateFormat ) {
82+ return moment ( value ) . format ( options . dateFormat ) ;
83+ }
84+ }
85+
7686 functions . number = { } ;
7787 functions . number . toscreen = function ( $element , val , rootVal , options ) {
7888 var number = Number ( val ) ;
@@ -82,6 +92,8 @@ define(['require', 'jquery', 'lodash', 'src/util/api', 'src/util/util'], functio
8292 number = number . toPrecision ( options . toPrecision ) ;
8393 } else if ( options . hasOwnProperty ( 'toFixed' ) ) {
8494 number = number . toFixed ( options . toFixed ) ;
95+ } else if ( checkDate ( options ) ) {
96+ number = toDate ( number , options ) ;
8597 }
8698 $element . html ( number ) ;
8799 } ;
0 commit comments