Add animated relative last-seen device timestamps
This commit is contained in:
@@ -32,7 +32,7 @@ export function formatTime(iso) {
|
||||
|
||||
export function formatLastSeen(iso, now = new Date()) {
|
||||
const date = new Date(iso);
|
||||
if (Number.isNaN(date.getTime())) return { label: "Нет данных", tooltip: "Нет данных" };
|
||||
if (Number.isNaN(date.getTime())) return { label: "Нет данных", relative: "Нет данных", tooltip: "Нет данных" };
|
||||
const current = new Date(now);
|
||||
const day = (value) => Date.UTC(value.getFullYear(), value.getMonth(), value.getDate());
|
||||
const daysAgo = Math.round((day(current) - day(date)) / 86_400_000);
|
||||
@@ -62,5 +62,5 @@ export function formatLastSeen(iso, now = new Date()) {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
return { label: `${dateLabel}, ${time}`, tooltip: `${full} (${relative})` };
|
||||
return { label: `${dateLabel}, ${time}`, relative, tooltip: `${full} (${relative})` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user