// Format the currency exports. formatmoney = function (s) {If (S = "undefined" | S = NULL) Return "0.00"; S = (S + ""). replace (",", ""); If (/[^ 0-9 \.] /. test (s) Return "format error"; S = S. replace (/^ (\ D *) $/, "$1. "); s = (S +" 00 "). replace (/(\ D *\. \ D) \ D */, "$1"); s = S. replace (". ",", "); var Re =/(\ D) (\ D {3},)/; while (Re. test (s) S = S. replace (Re, "$1, $2"); s = S. replace (/, (\ D) $ /,". $1 "); // return" ¥ "+ S. replace (/^ \. /, "0. ") return S. replace (/^ \. /, "0. ")}
// Format the time, for example, formatdate ("2010-04-30", "yyyy-mm-dd hh: mm: Ss. fff ") exports. formatdate = function (date, format) {If (! Date) Return ""; if (! Format) format = "yyyy-mm-dd hh: mm: SS"; Switch (typeof date) {Case "string": Date = new date (date. replace (/-/g, "/"); break; Case "Number": Date = new date (date); break;} If (! Date instanceof date) Return ""; var dict = {"YYYY": Date. getfullyear (), "M": Date. getmonth () + 1, "D": Date. getdate (), "H": Date. gethours (), "M": Date. getminutes (), "S": Date. getseconds (), "mm": ("" + (date. getmonth () + 101 )). substr (1), "DD": ("+ (date. getdate () + 100 )). substr (1), "hh": ("" + (date. gethours () + 100 )). substr (1), "mm": ("" + (date. getminutes () + 100 )). substr (1), "SS": ("" + (Date. Getseconds () + 100 )). substr (1), "fff": ("" + (date. getmilliseconds () + 1000 )). substr (1)}; return format. replace (/(yyyy | mm? | Dd? | Hh? | SS? | Mm? | Fff ?) /G, function () {return dict [arguments [0] ;});}
// Keep the digits after the decimal point. Do not round them to exports. fnum = function (VAL) {var arr _ = Val. tostring (). split ('. '); If (ARR _. length <2) {return val;} else if (ARR _ [1]. length <3) {return val;} else {return [arr _ [0], arr _ [1]. substring (0, 2)]. join ('. ');}}
Format currency time