const MONTH_REGEX = /^\d{4}-(0[1-9]|1[0-2])$/ export function getCurrentMonth(): string { const d = new Date() const offset = 8 * 60 * 60 * 1000 const local = new Date(d.getTime() + offset) return local.toISOString().slice(0, 7) } export function getMonthRange(m: string): { startDate: string; endDate: string } | null { if (!MONTH_REGEX.test(m)) return null const [year, mon] = m.split('-').map(Number) const startDate = `${m}-01` const lastDay = new Date(year, mon, 0).getDate() const endDate = `${m}-${String(lastDay).padStart(2, '0')}` return { startDate, endDate } }