27 lines
779 B
TypeScript
27 lines
779 B
TypeScript
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` (0–23, 0–59) 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
|
||
}
|