diff --git a/scripts/import-hk-parishes.ts b/scripts/import-hk-parishes.ts index ba7d712..2520507 100644 --- a/scripts/import-hk-parishes.ts +++ b/scripts/import-hk-parishes.ts @@ -114,7 +114,7 @@ export function extractFields(body: string): { address: string | null; phone: st const normalise = (s: string) => s.replace(/(/g, '(').replace(/)/g, ')').trim(); function extractField(fieldName: string): string | null { - const regex = new RegExp(`\\b${fieldName}\\n([\\s\\S]*?)(?:\\n\\n|\\nFax|\\nEmail|\\nWebsite|\\nChurch|\\nParish|\\nAssistant|\\nDeacon|\\nResident|\\nRector|\\nP\\.C|\\nPastoral|\\nMass Time|$)`, 'i'); + const regex = new RegExp(`\\b${fieldName}\\n([\\s\\S]*?)(?:\\n\\n|\\nFax|\\nEmail|\\nWebsite|\\nChurch|\\nParish|\\nAssistant|\\nDeacon|\\nSister|\\nChairperson|\\nResident|\\nRector|\\nP\\.C|\\nPastoral|\\nMass Time|$)`, 'i'); const m = body.match(regex); if (!m) return null; const value = m[1].replace(/\n/g, ' ').trim(); @@ -142,9 +142,9 @@ export function extractFields(body: string): { address: string | null; phone: st export function normalizeTime(raw: string): string | null { const s = raw.trim().toLowerCase(); if (s.includes('noon')) { + if (s === 'noon') return '12:00'; const m = s.match(/(\d{1,2}):(\d{2})\s*noon/); if (m) return `${String(parseInt(m[1], 10)).padStart(2, '0')}:${m[2]}`; - if (s === '12:00 noon' || s === '12:00noon') return '12:00'; } const m = s.match(/(\d{1,2}):(\d{2})\s*(am|pm|a\.m\.|p\.m\.)/); @@ -239,7 +239,11 @@ function parseDays(prefix: string): number[] { const fromDay = DAY_FULL[rangeMatch[1]] ?? DAY_ABBREV[rangeMatch[1]]; const toDay = DAY_FULL[rangeMatch[2]] ?? DAY_ABBREV[rangeMatch[2]]; if (fromDay !== undefined && toDay !== undefined) { - return Array.from({ length: toDay - fromDay + 1 }, (_, i) => fromDay + i); + const days: number[] = []; + let d = fromDay; + while (d !== toDay) { days.push(d); d = (d + 1) % 7; } + days.push(toDay); + return days; } }