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

Function fromSeconds

console/src/utils/format.ts:238–248  ·  view source on GitHub ↗
(
  totalSeconds: number,
)

Source from the content-addressed store, hash-verified

236/** Decompose a seconds value into the largest unit that divides it evenly,
237 * so 300 → 5 minutes, 3600 → 1 hour, 23 → 23 seconds. */
238export const fromSeconds = (
239 totalSeconds: number,
240): { amount: number; unit: DurationUnit } => {
241 for (const unit of Object.keys(SECONDS_PER_UNIT) as DurationUnit[]) {
242 const perUnit = SECONDS_PER_UNIT[unit];
243 if (totalSeconds % perUnit === 0) {
244 return { amount: totalSeconds / perUnit, unit };
245 }
246 }
247 return { amount: totalSeconds, unit: "seconds" };
248};

Callers 3

format.test.tsFile · 0.90
FreshnessFilterPanelFunction · 0.90
FilterChips.tsxFile · 0.90

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected