self-pr review

This commit is contained in:
Igor Loskutov
2025-09-12 18:34:56 -04:00
parent 1f41448e1c
commit 5d53c53db2
14 changed files with 486 additions and 886 deletions

View File

@@ -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";