* stage 1: project init * stage 2: skeleton with navigation * step 2.5: streams list * step 4: stream playback experience * step 5-6: compose experience * fix: broken record * transcode media particles to mp4 * build: reproducible go generate * build: rename skaffold module for particle processor worker * infra: increase particle processor worker resources Was dealing with OOM errors * tweaks to mobile * log transcode work * view on desktop placeholder * tweak padding * cap video resolution to save on memory * infra: bump memory limits as insurance * ux improvements * update bundle id for mobile * config for mobile
21 lines
807 B
TypeScript
21 lines
807 B
TypeScript
const MINUTE = 60;
|
|
const HOUR = 3600;
|
|
const DAY = 86400;
|
|
const WEEK = 604800;
|
|
const MONTH = 2592000;
|
|
const YEAR = 31536000;
|
|
|
|
export function formatDistanceToNow(date: Date | string): string {
|
|
const ms = typeof date === "string" ? new Date(date).getTime() : date.getTime();
|
|
const seconds = Math.floor((Date.now() - ms) / 1000);
|
|
|
|
if (seconds < 5) return "just now";
|
|
if (seconds < MINUTE) return `${seconds}s ago`;
|
|
if (seconds < HOUR) return `${Math.floor(seconds / MINUTE)}m ago`;
|
|
if (seconds < DAY) return `${Math.floor(seconds / HOUR)}h ago`;
|
|
if (seconds < WEEK) return `${Math.floor(seconds / DAY)}d ago`;
|
|
if (seconds < MONTH) return `${Math.floor(seconds / WEEK)}w ago`;
|
|
if (seconds < YEAR) return `${Math.floor(seconds / MONTH)}mo ago`;
|
|
return `${Math.floor(seconds / YEAR)}y ago`;
|
|
}
|