export const DAYS_VIEW_SPANS = ['1d', '3d', '5d', '7d', '9d', '11d', '14d'] as const export type DaysViewSpan = typeof DAYS_VIEW_SPANS[number] export const AGENDA_VIEW_SPANS = ['1d', '3d', '1w', '2w', '3w', '1m'] as const export type AgendaViewSpan = typeof AGENDA_VIEW_SPANS[number] export const SPAN_TO_DAYS = { '1d': 1, '3d': 3, '5d': 5, '7d': 7, '9d': 9, '11d': 11, '14d': 14, '1w': 7, '2w': 14, '3w': 21, '1m': 30, } as const export type TimeSpanLabel = keyof typeof SPAN_TO_DAYS export function spanToDays(span: TimeSpanLabel): number { return SPAN_TO_DAYS[span] } export function dayCountToDaysViewSpan(days: number): DaysViewSpan | null { const label = `${days}d` return DAYS_VIEW_SPANS.includes(label as DaysViewSpan) ? (label as DaysViewSpan) : null }