MCPcopy Create free account
hub / github.com/zxlie/FeHelper / pad

Function pad

apps/json-format/json-utils.js:359–364  ·  view source on GitHub ↗
(src, len)

Source from the content-addressed store, hash-verified

357// ─── 日期格式化(替代 Date.prototype.format 的纯函数版本)──
358export function formatDate(date, pattern) {
359 const pad = (src, len) => {
360 const neg = src < 0;
361 let s = String(Math.abs(src));
362 while (s.length < len) s = '0' + s;
363 return (neg ? '-' : '') + s;
364 };
365 if (typeof pattern !== 'string') return date.toString();
366
367 const y = date.getFullYear();

Callers 1

formatDateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected