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

Function ParseDTime

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

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

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

Source from the content-addressed store, hash-verified

2304// The dependsOnContext return value indicates if we had to consult the
2305// ParseContext (either for the time or the local timezone).
2306func ParseDTime(
2307 ctx ParseContext, s string, precision time.Duration,
2308) (_ *DTime, dependsOnContext bool, _ error) {
2309 now := relativeParseTime(ctx)
2310
2311 // Special case on 24:00 and 24:00:00 as the parser
2312 // does not handle these correctly.
2313 if DTimeMaxTimeRegex.MatchString(s) {
2314 return MakeDTime(timeofday.Time2400), false, nil
2315 }
2316
2317 s = timeutil.ReplaceLibPQTimePrefix(s)
2318
2319 t, dependsOnContext, err := pgdate.ParseTimeWithoutTimezone(now, dateStyle(ctx), s, dateParseHelper(ctx))
2320 if err != nil {
2321 return nil, false, MakeParseError(s, types.Time, err)
2322 }
2323 return MakeDTime(timeofday.FromTime(t).Round(precision)), dependsOnContext, nil
2324}
2325
2326// ResolvedType implements the TypedExpr interface.
2327func (*DTime) ResolvedType() *types.T {

Callers 1

ParseAndRequireStringFunction · 0.85

Calls 9

ReplaceLibPQTimePrefixFunction · 0.92
ParseTimeWithoutTimezoneFunction · 0.92
FromTimeFunction · 0.92
relativeParseTimeFunction · 0.85
MakeDTimeFunction · 0.85
dateStyleFunction · 0.85
dateParseHelperFunction · 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…