MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / fmtTuple

Function fmtTuple

host/time/src/main/fmt.js:23–31  ·  view source on GitHub ↗
(t, fmt)

Source from the content-addressed store, hash-verified

21const resolve = (t) => (t !== undefined ? JSON.parse(t) : JSON.parse(toTuple(new Date(), false)));
22
23const fmtTuple = (t, fmt) => {
24 const [Y, mo, d, H, Mi, S, w, j] = t;
25 const map = {
26 Y, y: pad(Y % 100), m: pad(mo), d: pad(d), H: pad(H), M: pad(Mi), S: pad(S),
27 I: pad((H % 12) || 12), p: H < 12 ? "AM" : "PM", j: pad(j, 3), w: jsDay(w),
28 a: DAYS_ABBR[jsDay(w)], A: DAYS[jsDay(w)], b: MONTHS_ABBR[mo - 1], B: MONTHS[mo - 1], "%": "%",
29 };
30 return fmt.replace(/%(.)/g, (_, c) => (c in map ? String(map[c]) : "%" + c));
31};
32
33// "Thu Jan 1 00:00:00 1970", day-of-month space-padded to width 2.
34const ascForm = (t) => `${DAYS_ABBR[jsDay(t[6])]} ${MONTHS_ABBR[t[1] - 1]} ${String(t[2]).padStart(2, " ")} ${pad(t[3])}:${pad(t[4])}:${pad(t[5])} ${t[0]}`;

Callers 1

fmt.jsFile · 0.85

Calls 2

padFunction · 0.85
jsDayFunction · 0.85

Tested by

no test coverage detected