Improve formatting

This commit is contained in:
2023-04-11 16:02:54 +02:00
parent 268128c2f4
commit 6c9546b74a
22 changed files with 280 additions and 279 deletions

View File

@ -11,10 +11,7 @@ export const time = readable(new Date(), function start(set) {
});
export function secondsSince(date: Date): Readable<number> {
return derived(
time,
$time => Math.round(($time.getTime() - date.getTime()) / 1000)
);
return derived(time, ($time) => Math.round(($time.getTime() - date.getTime()) / 1000));
}
export function relativeTime(seconds: number): string | null {
@ -30,11 +27,11 @@ export function relativeTime(seconds: number): string | null {
const day = hour * 24;
if (seconds < day) {
return `${(Math.floor(seconds / hour))}h`;
return `${Math.floor(seconds / hour)}h`;
}
const maxRelative = day * 31;
if (seconds < maxRelative) {
return `${Math.floor(seconds / day)}d`;
}
return null;
}
}