@graphteon/juricode
Version:
We are forging the future with lines of digital steel
26 lines • 851 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTimeDelta = void 0;
const formatTimeDelta = (date) => {
const now = new Date();
const delta = now.getTime() - date.getTime();
const seconds = Math.floor(delta / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
const months = Math.floor(days / 30);
const years = Math.floor(months / 12);
if (seconds < 60)
return `${seconds}s`;
if (minutes < 60)
return `${minutes}m`;
if (hours < 24)
return `${hours}h`;
if (days < 30)
return `${days}d`;
if (months < 12)
return `${months}mo`;
return `${years}y`;
};
exports.formatTimeDelta = formatTimeDelta;
//# sourceMappingURL=format-time-delta.js.map