[skip ci] Initial commit — CodexBar Mobile Expo app
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
export function formatResetCountdown(resetAtSeconds: number): string {
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
const diffSeconds = resetAtSeconds - nowSeconds;
|
||||
|
||||
if (diffSeconds <= 0) return "resetting now";
|
||||
if (diffSeconds < 60) return "resets in <1m";
|
||||
|
||||
const hours = Math.floor(diffSeconds / 3600);
|
||||
const minutes = Math.floor((diffSeconds % 3600) / 60);
|
||||
|
||||
if (hours > 0 && minutes > 0) return `resets in ${hours}h ${minutes}m`;
|
||||
if (hours > 0) return `resets in ${hours}h`;
|
||||
return `resets in ${minutes}m`;
|
||||
}
|
||||
|
||||
export function formatResetCountdownISO(isoString: string): string {
|
||||
const resetAtSeconds = Math.floor(new Date(isoString).getTime() / 1000);
|
||||
return formatResetCountdown(resetAtSeconds);
|
||||
}
|
||||
|
||||
export function windowLabel(limitWindowSeconds: number): string {
|
||||
if (limitWindowSeconds <= 3600) return "1h window";
|
||||
if (limitWindowSeconds <= 86400) return "24h window";
|
||||
return `${Math.round(limitWindowSeconds / 3600)}h window`;
|
||||
}
|
||||
Reference in New Issue
Block a user