@@ -94,16 +94,16 @@ function CadenceOption({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatResetLocal(resetAt: Date): string {
|
function formatResetLocal(resetAt: Date): string {
|
||||||
const now = new Date();
|
const time = resetAt.toLocaleTimeString(undefined, {
|
||||||
const diffMs = resetAt.getTime() - now.getTime();
|
|
||||||
const hours = Math.max(0, Math.round(diffMs / (60 * 60 * 1000)));
|
|
||||||
const absolute = resetAt.toLocaleTimeString(undefined, {
|
|
||||||
hour: "numeric",
|
hour: "numeric",
|
||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
});
|
});
|
||||||
if (hours < 1) return `soon (${absolute})`;
|
const now = new Date();
|
||||||
if (hours === 1) return `in 1 hour (${absolute})`;
|
const isSameDay =
|
||||||
return `in ${hours} hours (${absolute})`;
|
resetAt.getFullYear() === now.getFullYear() &&
|
||||||
|
resetAt.getMonth() === now.getMonth() &&
|
||||||
|
resetAt.getDate() === now.getDate();
|
||||||
|
return `${isSameDay ? "today" : "tomorrow"} at ${time}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user