parseLogTimestamp handles both float epoch seconds and string ISO timestamps.
(ts json.Number)
| 70 | |
| 71 | // parseLogTimestamp handles both float epoch seconds and string ISO timestamps. |
| 72 | func parseLogTimestamp(ts json.Number) *string { |
| 73 | if ts == "" { |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | if f, err := strconv.ParseFloat(string(ts), 64); err == nil { |
| 78 | sec := int64(f) |
| 79 | nsec := int64((f - float64(sec)) * 1e9) |
| 80 | t := time.Unix(sec, nsec).UTC().Format(time.RFC3339Nano) |
| 81 | return &t |
| 82 | } |
| 83 | |
| 84 | s := string(ts) |
| 85 | return &s |
| 86 | } |