MCPcopy Create free account
hub / github.com/codicocodes/speedtyper.dev / humanizeAbsolute

Function humanizeAbsolute

packages/webapp-next/utils/humanize.ts:16–26  ·  view source on GitHub ↗
(when: Date | number)

Source from the content-addressed store, hash-verified

14};
15
16export function humanizeAbsolute(when: Date | number) {
17 const diff =
18 new Date().getTime() - (typeof when === "number" ? when : when.getTime());
19 for (const unit in TIME_UNITS) {
20 const quotient = Math.floor(diff / TIME_UNITS[unit]);
21 if (quotient > 0) {
22 return `${quotient} ${unit}${quotient > 1 ? "s" : ""}`;
23 }
24 }
25 return "just now";
26}
27
28export function humanizeRelative(pastMilliseconds: number) {
29 return humanizeAbsolute(new Date().getTime() - pastMilliseconds);

Callers 2

WPMLeaderboardFunction · 0.90
humanizeRelativeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected