MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / formatInterval

Function formatInterval

console/src/utils/format.ts:171–200  ·  view source on GitHub ↗
(interval: IPostgresInterval)

Source from the content-addressed store, hash-verified

169}
170
171export function formatInterval(interval: IPostgresInterval) {
172 const parts: string[] = [];
173
174 if (interval.years) {
175 parts.push(`${interval.years}y`);
176 }
177 if (interval.months) {
178 parts.push(`${interval.months}m`);
179 }
180 if (interval.days) {
181 parts.push(`${interval.days}d`);
182 }
183 if (interval.hours) {
184 parts.push(`${interval.hours}h`);
185 }
186 if (interval.minutes) {
187 parts.push(`${interval.minutes}m`);
188 }
189 if (interval.seconds || interval.milliseconds) {
190 parts.push(
191 `${interval.seconds || 0}.${(interval.milliseconds || 0).toString().padStart(3, "0")}s`,
192 );
193 }
194
195 if (parts.length === 0) {
196 return "0s";
197 }
198
199 return parts.join(" ");
200}
201
202export function formatDurationForAxis(durationMs: number): string {
203 // Cap at 24 hours (86,400,000 ms)

Callers 5

FreshnessGraphInnerFunction · 0.90
format.test.tsFile · 0.90
ClusterFreshnessTableFunction · 0.90
SourceOverviewFunction · 0.90
ClusterFreshnessTableFunction · 0.90

Calls 2

pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected