parseEventTimestamp extracts the timestamp from an event map. Returns the timestamp string, falling back to current time if not present or invalid.
(event map[string]any)
| 359 | // parseEventTimestamp extracts the timestamp from an event map. |
| 360 | // Returns the timestamp string, falling back to current time if not present or invalid. |
| 361 | func parseEventTimestamp(event map[string]any) string { |
| 362 | if ts, ok := event["timestamp"].(string); ok && ts != "" { |
| 363 | // Validate RFC3339 format |
| 364 | if _, err := time.Parse(time.RFC3339, ts); err == nil { |
| 365 | return ts |
| 366 | } |
| 367 | // Invalid timestamp format - fall back to current time |
| 368 | } |
| 369 | return time.Now().Format(time.RFC3339) |
| 370 | } |
| 371 | |
| 372 | // SaveRunJSON saves the eval run results to a JSON file. |
| 373 | // This is kept for backward compatibility and debugging purposes. |
no test coverage detected