MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / formatDate

Function formatDate

framework/utils/lib/common.ts:62–80  ·  view source on GitHub ↗
(date: Date, fmt = '%Y-%m-%d %H:%M:%S')

Source from the content-addressed store, hash-verified

60}
61
62export function formatDate(date: Date, fmt = '%Y-%m-%d %H:%M:%S') {
63 let m = (date.getMonth() + 1).toString();
64 if (m.length < 2) m = `0${m}`;
65 let d = date.getDate().toString();
66 if (d.length < 2) d = `0${d}`;
67 let H = date.getHours().toString();
68 if (H.length < 2) H = `0${H}`;
69 let M = date.getMinutes().toString();
70 if (M.length < 2) M = `0${M}`;
71 let S = date.getSeconds().toString();
72 if (S.length < 2) S = `0${S}`;
73 return fmt
74 .replace('%Y', date.getFullYear().toString())
75 .replace('%m', m)
76 .replace('%d', d)
77 .replace('%H', H)
78 .replace('%M', M)
79 .replace('%S', S);
80}
81
82Math.sum = function sum(...args) {
83 let s = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected