MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / parseEnglishUtcDate

Function parseEnglishUtcDate

packages/parser/src/formats/google-chat-takeout.ts:149–167  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

147}
148
149function parseEnglishUtcDate(value: string): number | null {
150 const match = normalizeSpaces(value).match(
151 /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),\s+([A-Za-z]+)\s+(\d{1,2}),\s+(\d{4})\s+at\s+(\d{1,2}):(\d{2}):(\d{2})\s+(AM|PM)\s+UTC$/i
152 )
153 if (!match) return null
154
155 const monthIndex = ENGLISH_MONTHS.get(match[1].toLowerCase())
156 if (monthIndex === undefined) return null
157
158 let hour = Number(match[4])
159 if (hour < 1 || hour > 12) return null
160 if (match[7].toUpperCase() === 'AM') {
161 if (hour === 12) hour = 0
162 } else if (hour !== 12) {
163 hour += 12
164 }
165
166 return createUtcTimestamp(Number(match[3]), monthIndex, Number(match[2]), hour, Number(match[5]), Number(match[6]))
167}
168
169/**
170 * Google Takeout 会根据导出语言生成本地化日期文本。这里只接受已验证的

Callers 1

parseGoogleChatDateFunction · 0.85

Calls 3

normalizeSpacesFunction · 0.85
createUtcTimestampFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected