MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / formatTime

Function formatTime

packages/web/src/lib/utils.ts:471–480  ·  view source on GitHub ↗
(value: number, unit: 'minute' | 'hour' | 'day' | 'month', isFuture: boolean)

Source from the content-addressed store, hash-verified

469 const months = days / 30;
470
471 const formatTime = (value: number, unit: 'minute' | 'hour' | 'day' | 'month', isFuture: boolean) => {
472 const roundedValue = Math.floor(value);
473 const pluralUnit = roundedValue === 1 ? unit : `${unit}s`;
474
475 if (isFuture) {
476 return `In ${roundedValue} ${pluralUnit}`;
477 } else {
478 return `${roundedValue} ${pluralUnit} ago`;
479 }
480 }
481
482 if (minutes < 1) {
483 return 'just now';

Callers 1

getFormattedDateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected