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, )
| 2304 | // The dependsOnContext return value indicates if we had to consult the |
| 2305 | // ParseContext (either for the time or the local timezone). |
| 2306 | func 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. |
| 2327 | func (*DTime) ResolvedType() *types.T { |
no test coverage detected
searching dependent graphs…