MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / formatRelativeTime

Function formatRelativeTime

src/components/CronJobCard.tsx:122–139  ·  view source on GitHub ↗
(dateString: string)

Source from the content-addressed store, hash-verified

120}
121
122function formatRelativeTime(dateString: string): string {
123 const diffMs = new Date(dateString).getTime() - Date.now();
124 const absMs = Math.abs(diffMs);
125 const units = [
126 { size: 24 * 60 * 60 * 1000, label: "d" },
127 { size: 60 * 60 * 1000, label: "h" },
128 { size: 60 * 1000, label: "m" },
129 ];
130
131 for (const unit of units) {
132 if (absMs >= unit.size) {
133 const value = Math.round(absMs / unit.size);
134 return diffMs >= 0 ? `in ${value}${unit.label}` : `${value}${unit.label} ago`;
135 }
136 }
137
138 return diffMs >= 0 ? "any moment now" : "just now";
139}
140
141function formatDuration(durationMs?: number | null): string {
142 if (typeof durationMs !== "number" || Number.isNaN(durationMs)) {

Callers 1

getTimeMetaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected