* Parse datetime string to Date object * Supports ISO 8601 with timezone, 'now', or legacy date-only format
(datetimeStr: string)
| 269 | * Supports ISO 8601 with timezone, 'now', or legacy date-only format |
| 270 | */ |
| 271 | function 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 |
no outgoing calls
no test coverage detected