MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / normalizeTimestamp

Function normalizeTimestamp

luckmail-utils.js:31–56  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

29 }
30
31 function normalizeTimestamp(value) {
32 if (!value) return 0;
33 if (typeof value === 'number' && Number.isFinite(value)) {
34 return value > 0 ? value : 0;
35 }
36
37 const rawValue = String(value || '').trim();
38 const utcLikeMatch = rawValue.match(
39 /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})(?::(\d{2}))?$/
40 );
41 if (utcLikeMatch && !/[zZ]|[+\-]\d{2}:?\d{2}$/.test(rawValue)) {
42 const [, year, month, day, hour, minute, second = '0'] = utcLikeMatch;
43 return Date.UTC(
44 Number(year),
45 Number(month) - 1,
46 Number(day),
47 Number(hour),
48 Number(minute),
49 Number(second),
50 0
51 );
52 }
53
54 const timestamp = Date.parse(rawValue);
55 return Number.isFinite(timestamp) ? timestamp : 0;
56 }
57
58 function normalizeLuckmailBaseUrl(rawValue = '') {
59 const value = String(rawValue || '').trim();

Callers 4

Calls

no outgoing calls

Tested by

no test coverage detected