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

Function ParseDTime

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

ParseDTime parses and returns the *DTime Datum value represented by the provided string, or an error if parsing is unsuccessful.

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

Source from the content-addressed store, hash-verified

1918// ParseDTime parses and returns the *DTime Datum value represented by the
1919// provided string, or an error if parsing is unsuccessful.
1920func ParseDTime(ctx ParseTimeContext, s string, precision time.Duration) (*DTime, error) {
1921 now := relativeParseTime(ctx)
1922
1923 // Special case on 24:00 and 24:00:00 as the parser
1924 // does not handle these correctly.
1925 if DTimeMaxTimeRegex.MatchString(s) {
1926 return MakeDTime(timeofday.Time2400), nil
1927 }
1928
1929 s = timeutil.ReplaceLibPQTimePrefix(s)
1930
1931 t, err := pgdate.ParseTime(now, pgdate.ParseModeYMD, s)
1932 if err != nil {
1933 // Build our own error message to avoid exposing the dummy date.
1934 return nil, makeParseError(s, types.Time, nil)
1935 }
1936 return MakeDTime(timeofday.FromTime(t).Round(precision)), nil
1937}
1938
1939// ResolvedType implements the TypedExpr interface.
1940func (*DTime) ResolvedType() *types.T {

Callers 2

ParseAndRequireStringFunction · 0.85
PerformCastFunction · 0.85

Calls 7

ReplaceLibPQTimePrefixFunction · 0.92
ParseTimeFunction · 0.92
FromTimeFunction · 0.92
relativeParseTimeFunction · 0.85
MakeDTimeFunction · 0.85
makeParseErrorFunction · 0.85
RoundMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…