mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
self-pr review
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
export const formatDateTime = (date: string | Date): string => {
|
||||
const d = new Date(date);
|
||||
export const formatDateTime = (d: Date): string => {
|
||||
return d.toLocaleString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
@@ -8,26 +7,11 @@ export const formatDateTime = (date: string | Date): string => {
|
||||
});
|
||||
};
|
||||
|
||||
export const formatCountdown = (startTime: string | Date): string => {
|
||||
const now = new Date();
|
||||
const start = new Date(startTime);
|
||||
const diff = start.getTime() - now.getTime();
|
||||
|
||||
if (diff <= 0) return "Starting now";
|
||||
|
||||
const minutes = Math.floor(diff / 60000);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (days > 0) return `Starts in ${days}d ${hours % 24}h ${minutes % 60}m`;
|
||||
if (hours > 0) return `Starts in ${hours}h ${minutes % 60}m`;
|
||||
return `Starts in ${minutes} minutes`;
|
||||
};
|
||||
|
||||
export const formatStartedAgo = (startTime: string | Date): string => {
|
||||
const now = new Date();
|
||||
const start = new Date(startTime);
|
||||
const diff = now.getTime() - start.getTime();
|
||||
export const formatStartedAgo = (
|
||||
startTime: Date,
|
||||
now: Date = new Date(),
|
||||
): string => {
|
||||
const diff = now.getTime() - startTime.getTime();
|
||||
|
||||
if (diff <= 0) return "Starting now";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user