MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ParseDTimestampTZ

Function ParseDTimestampTZ

postgres/parser/sem/tree/datum.go:1094–1109  ·  view source on GitHub ↗

ParseDTimestampTZ parses and returns the *DTimestampTZ Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful. The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

(ctx ParseTimeContext, s string, precision time.Duration, loc *time.Location)

Source from the content-addressed store, hash-verified

1092// The dependsOnContext return value indicates if we had to consult the
1093// ParseTimeContext (either for the time or the local timezone).
1094func ParseDTimestampTZ(ctx ParseTimeContext, s string, precision time.Duration, loc *time.Location) (_ *DTimestampTZ, dependsOnContext bool, _ error) {
1095 now := relativeParseTime(ctx).In(loc)
1096 t, dependsOnContext, err := pgdate.ParseTimestamp(now, pgdate.ParseModeYMD, s)
1097 if err != nil {
1098 t, dependsOnContext, err = pgdate.ParseTimestamp(now, pgdate.ParseModeDMY, s)
1099 if err != nil {
1100 t, dependsOnContext, err = pgdate.ParseTimestamp(now, pgdate.ParseModeMDY, s)
1101 if err != nil {
1102 return nil, false, err
1103 }
1104 }
1105 }
1106 // Always normalize time to the current location.
1107 d, err := MakeDTimestampTZ(t, precision)
1108 return d, dependsOnContext, err
1109}
1110
1111// Round returns a new DTimestampTZ to the specified precision.
1112func (d *DTimestampTZ) Round(precision time.Duration) (*DTimestampTZ, error) {

Callers 2

timestamptz.goFile · 0.92
ParseAndRequireStringFunction · 0.85

Calls 3

ParseTimestampFunction · 0.92
relativeParseTimeFunction · 0.85
MakeDTimestampTZFunction · 0.85

Tested by

no test coverage detected