MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / ParseDTimestamp

Function ParseDTimestamp

pkg/sql/sem/tree/datum.go:2154–2164  ·  view source on GitHub ↗

ParseDTimestamp parses and returns the *DTimestamp Datum value represented by the provided string in UTC, or an error if parsing is unsuccessful.

(ctx ParseTimeContext, s string, precision time.Duration)

Source from the content-addressed store, hash-verified

2152// ParseDTimestamp parses and returns the *DTimestamp Datum value represented by
2153// the provided string in UTC, or an error if parsing is unsuccessful.
2154func ParseDTimestamp(ctx ParseTimeContext, s string, precision time.Duration) (*DTimestamp, error) {
2155 now := relativeParseTime(ctx)
2156 t, err := pgdate.ParseTimestamp(now, pgdate.ParseModeYMD, s)
2157 if err != nil {
2158 return nil, err
2159 }
2160 // Truncate the timezone. DTimestamp doesn't carry its timezone around.
2161 _, offset := t.Zone()
2162 t = t.Add(time.Duration(offset) * time.Second).UTC()
2163 return MakeDTimestamp(t, precision), nil
2164}
2165
2166// AsDTimestamp attempts to retrieve a DTimestamp from an Expr, returning a DTimestamp and
2167// a flag signifying whether the assertion was successful. The function should

Callers 3

DatumToHLCFunction · 0.85
ParseAndRequireStringFunction · 0.85
PerformCastFunction · 0.85

Calls 4

ParseTimestampFunction · 0.92
relativeParseTimeFunction · 0.85
MakeDTimestampFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…