(tpl: string, value: unknown, isUTC?: boolean)
| 247 | * @inner |
| 248 | */ |
| 249 | export function formatTime(tpl: string, value: unknown, isUTC?: boolean) { |
| 250 | if (__DEV__) { |
| 251 | deprecateReplaceLog('echarts.format.formatTime', 'echarts.time.format'); |
| 252 | } |
| 253 | |
| 254 | if (tpl === 'week' |
| 255 | || tpl === 'month' |
| 256 | || tpl === 'quarter' |
| 257 | || tpl === 'half-year' |
| 258 | || tpl === 'year' |
| 259 | ) { |
| 260 | tpl = 'MM-dd\nyyyy'; |
| 261 | } |
| 262 | |
| 263 | const date = parseDate(value); |
| 264 | const getUTC = isUTC ? 'getUTC' : 'get'; |
| 265 | const y = (date as any)[getUTC + 'FullYear'](); |
| 266 | const M = (date as any)[getUTC + 'Month']() + 1; |
| 267 | const d = (date as any)[getUTC + 'Date'](); |
| 268 | const h = (date as any)[getUTC + 'Hours'](); |
| 269 | const m = (date as any)[getUTC + 'Minutes'](); |
| 270 | const s = (date as any)[getUTC + 'Seconds'](); |
| 271 | const S = (date as any)[getUTC + 'Milliseconds'](); |
| 272 | |
| 273 | tpl = tpl.replace('MM', pad(M, 2)) |
| 274 | .replace('M', M) |
| 275 | .replace('yyyy', y) |
| 276 | .replace('yy', pad(y % 100 + '', 2)) |
| 277 | .replace('dd', pad(d, 2)) |
| 278 | .replace('d', d) |
| 279 | .replace('hh', pad(h, 2)) |
| 280 | .replace('h', h) |
| 281 | .replace('mm', pad(m, 2)) |
| 282 | .replace('m', m) |
| 283 | .replace('ss', pad(s, 2)) |
| 284 | .replace('s', s) |
| 285 | .replace('SSS', pad(S, 3)); |
| 286 | |
| 287 | return tpl; |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Capital first |
nothing calls this directly
no test coverage detected