MCPcopy Create free account
hub / github.com/lib/pq / parseTS

Function parseTS

encode.go:297–315  ·  view source on GitHub ↗

This is a time function specific to the Postgres default DateStyle setting ("ISO, MDY"), the only one we currently support. This accounts for the discrepancies between the parsing available with time.Parse and the Postgres date formatting quirks.

(currentLocation *time.Location, str string)

Source from the content-addressed store, hash-verified

295// discrepancies between the parsing available with time.Parse and the Postgres
296// date formatting quirks.
297func parseTS(currentLocation *time.Location, str string) (any, error) {
298 switch str {
299 case "-infinity":
300 if infinityTSEnabled {
301 return infinityTSNegative, nil
302 }
303 return []byte(str), nil
304 case "infinity":
305 if infinityTSEnabled {
306 return infinityTSPositive, nil
307 }
308 return []byte(str), nil
309 }
310 t, err := ParseTimestamp(currentLocation, str)
311 if err != nil {
312 err = errors.New("pq: " + err.Error())
313 }
314 return t, err
315}
316
317// ParseTimestamp parses Postgres' text format. It returns a time.Time in
318// currentLocation iff that time's offset agrees with the offset sent from the

Callers 1

textDecodeFunction · 0.85

Calls 2

ParseTimestampFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…