MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / normalizeTimestamp

Function normalizeTimestamp

utils/userStatus.js:16–39  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

14 * @returns {number|null} Normalized timestamp in milliseconds or null if invalid.
15 */
16const normalizeTimestamp = (value) => {
17 if (value == null) {
18 return null;
19 }
20
21 if (typeof value === "string") {
22 const trimmed = value.trim();
23 if (trimmed === "") {
24 return null;
25 }
26 const parsed = Number(trimmed);
27 return Number.isFinite(parsed) ? parsed : null;
28 }
29
30 if (typeof value === "number") {
31 return Number.isFinite(value) ? value : null;
32 }
33
34 if (value?.toMillis && typeof value.toMillis === "function") {
35 return value.toMillis();
36 }
37
38 return null;
39};
40
41/**
42 * Determines the timestamp to persist in the `lastOooUntil` field based on state transitions.

Callers 5

resolveLastOooUntilFunction · 0.85
getApprovedOooPeriodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected