MCPcopy Create free account
hub / github.com/NevaMind-AI/memUBot / parseDatetime

Function parseDatetime

src/main/tools/feishu.executor.ts:271–289  ·  view source on GitHub ↗

* Parse datetime string to Date object * Supports ISO 8601 with timezone, 'now', or legacy date-only format

(datetimeStr: string)

Source from the content-addressed store, hash-verified

269 * Supports ISO 8601 with timezone, 'now', or legacy date-only format
270 */
271function parseDatetime(datetimeStr: string): Date {
272 if (datetimeStr.toLowerCase() === 'now') {
273 return new Date()
274 }
275
276 // If it's a date-only format (YYYY-MM-DD), append local timezone
277 if (/^\d{4}-\d{2}-\d{2}$/.test(datetimeStr)) {
278 // Parse as local time by appending T00:00:00
279 return new Date(datetimeStr + 'T00:00:00')
280 }
281
282 // If it has time but no timezone, assume local time
283 if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/.test(datetimeStr)) {
284 return new Date(datetimeStr)
285 }
286
287 // Full ISO 8601 with timezone
288 return new Date(datetimeStr)
289}
290
291/**
292 * Delete chat history

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected