MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / formatTime

Function formatTime

libs/echarts/echarts.simple.js:19475–19510  ·  view source on GitHub ↗

* ISO Date format * @param {string} tpl * @param {number} value * @param {boolean} [isUTC=false] Default in local time. * see `module:echarts/scale/Time` * and `module:echarts/util/number#parseDate`. * @inner

(tpl, value, isUTC)

Source from the content-addressed store, hash-verified

19473 * @inner
19474 */
19475function formatTime(tpl, value, isUTC) {
19476 if (tpl === 'week'
19477 || tpl === 'month'
19478 || tpl === 'quarter'
19479 || tpl === 'half-year'
19480 || tpl === 'year'
19481 ) {
19482 tpl = 'MM-dd\nyyyy';
19483 }
19484
19485 var date = parseDate(value);
19486 var utc = isUTC ? 'UTC' : '';
19487 var y = date['get' + utc + 'FullYear']();
19488 var M = date['get' + utc + 'Month']() + 1;
19489 var d = date['get' + utc + 'Date']();
19490 var h = date['get' + utc + 'Hours']();
19491 var m = date['get' + utc + 'Minutes']();
19492 var s = date['get' + utc + 'Seconds']();
19493 var S = date['get' + utc + 'Milliseconds']();
19494
19495 tpl = tpl.replace('MM', pad(M, 2))
19496 .replace('M', M)
19497 .replace('yyyy', y)
19498 .replace('yy', y % 100)
19499 .replace('dd', pad(d, 2))
19500 .replace('d', d)
19501 .replace('hh', pad(h, 2))
19502 .replace('h', h)
19503 .replace('mm', pad(m, 2))
19504 .replace('m', m)
19505 .replace('ss', pad(s, 2))
19506 .replace('s', s)
19507 .replace('SSS', pad(S, 3));
19508
19509 return tpl;
19510}
19511
19512/**
19513 * Capital first

Callers 2

setEachItemFunction · 0.70
echarts.simple.jsFile · 0.70

Calls 2

parseDateFunction · 0.70
padFunction · 0.70

Tested by

no test coverage detected