Improve formatting
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user