MCPcopy Create free account
hub / github.com/Vespa314/cflow / getNormalizedTimeString

Function getNormalizedTimeString

web/src/helpers/datetime.ts:153–168  ·  view source on GitHub ↗
(t?: Date | number | string)

Source from the content-addressed store, hash-verified

151 * If no date is provided, the current date is used.
152 */
153export function getNormalizedTimeString(t?: Date | number | string): string {
154 const date = new Date(t ? t : Date.now());
155
156 const yyyy = date.getFullYear();
157 const M = date.getMonth() + 1;
158 const d = date.getDate();
159 const h = date.getHours();
160 const m = date.getMinutes();
161
162 const MM = M < 10 ? "0" + M : M;
163 const dd = d < 10 ? "0" + d : d;
164 const hh = h < 10 ? "0" + h : h;
165 const mm = m < 10 ? "0" + m : m;
166
167 return `${yyyy}-${MM}-${dd}T${hh}:${mm}`;
168}
169
170/**
171 * This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the provided date.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected