MCPcopy Create free account
hub / github.com/buggregator/server / parseTimestamp

Function parseTimestamp

modules/sentry/store_error.go:151–171  ·  view source on GitHub ↗

parseTimestamp converts a Sentry timestamp (float64 epoch seconds or ISO string) to an RFC3339 string.

(ts json.Number)

Source from the content-addressed store, hash-verified

149
150// parseTimestamp converts a Sentry timestamp (float64 epoch seconds or ISO string) to an RFC3339 string.
151func parseTimestamp(ts json.Number) *string {
152 if ts == "" {
153 return nil
154 }
155
156 // Try as float (epoch seconds).
157 if f, err := strconv.ParseFloat(string(ts), 64); err == nil {
158 sec := int64(f)
159 nsec := int64((f - float64(sec)) * 1e9)
160 t := time.Unix(sec, nsec).UTC().Format(time.RFC3339Nano)
161 return &t
162 }
163
164 // Try as string (ISO 8601).
165 s := string(ts)
166 if _, err := time.Parse(time.RFC3339, s); err == nil {
167 return &s
168 }
169
170 return &s
171}

Callers 3

storeErrorEventFunction · 0.70
storeTransactionFunction · 0.70
storeSpansV2Function · 0.70

Calls 1

ParseMethod · 0.80

Tested by

no test coverage detected