ultisuite-client/lib/utils.ts
2026-05-15 17:40:17 +02:00

27 lines
779 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
/** Fixed locale so SSR and browser output match (avoids hydration mismatch). */
const countFormatter = new Intl.NumberFormat('en-US')
export function formatCount(value: number): string {
return countFormatter.format(value)
}
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
/**
* Next occurrence of `hour`:`minute` (023, 059) in the local timezone.
* If that time today is still in the future, returns today; otherwise tomorrow.
*/
export function getNextLocalWallClockDate(hour: number, minute = 0): Date {
const d = new Date()
d.setHours(hour, minute, 0, 0)
if (d.getTime() <= Date.now()) {
d.setDate(d.getDate() + 1)
}
return d
}