MCPcopy Create free account
hub / github.com/denoland/std / #printDate

Method #printDate

toml/stringify.ts:209–222  ·  view source on GitHub ↗
(value: Date)

Source from the content-addressed store, hash-verified

207 return `${this.#declaration(keys)}${value}`;
208 }
209 #printDate(value: Date): string {
210 function dtPad(v: string, lPad = 2): string {
211 return v.padStart(lPad, "0");
212 }
213 const m = dtPad((value.getUTCMonth() + 1).toString());
214 const d = dtPad(value.getUTCDate().toString());
215 const h = dtPad(value.getUTCHours().toString());
216 const min = dtPad(value.getUTCMinutes().toString());
217 const s = dtPad(value.getUTCSeconds().toString());
218 const ms = dtPad(value.getUTCMilliseconds().toString(), 3);
219 // formatted date
220 const fData = `${value.getUTCFullYear()}-${m}-${d}T${h}:${min}:${s}.${ms}`;
221 return fData;
222 }
223 #dateDeclaration(keys: string[], value: Date): string {
224 return `${this.#declaration(keys)}${this.#printDate(value)}`;
225 }

Callers 2

#printAsInlineValueMethod · 0.95
#dateDeclarationMethod · 0.95

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected