19 lines
626 B
TypeScript
19 lines
626 B
TypeScript
/** Keep rows on or before the dashboard publish cutoff date (ISO `YYYY-MM-DD`). */
|
|
export function throughVisibleDate<T extends { date: string }>(
|
|
rows: T[],
|
|
visibleThrough: string | null | undefined
|
|
): T[] {
|
|
if (!visibleThrough) return rows;
|
|
return rows.filter((row) => row.date <= visibleThrough);
|
|
}
|
|
|
|
/** True when `date` is on or before the publish cutoff (or cutoff is unknown). */
|
|
export function isOnOrBeforeVisibleDate(
|
|
date: string | null | undefined,
|
|
visibleThrough: string | null | undefined
|
|
): boolean {
|
|
if (!date) return false;
|
|
if (!visibleThrough) return true;
|
|
return date <= visibleThrough;
|
|
}
|