/** Time helpers kept out of component bodies (the React compiler lint flags Date.now() during render). */
export function nowMs(): number {
  return Date.now()
}

/** True when there is no expiry or it is still in the future. */
export function notExpired(iso: string | null | undefined): boolean {
  return !iso || Date.parse(iso) > Date.now()
}

/** True when `iso` is within `ms` of now. */
export function withinMs(iso: string | null | undefined, ms: number): boolean {
  return !!iso && Date.now() - Date.parse(iso) < ms
}
