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 ParseTimeContext (either for the time or the local timezone).
( ctx ParseTimeContext, s string, precision time.Duration, )
| 861 | // The dependsOnContext return value indicates if we had to consult the |
| 862 | // ParseTimeContext (either for the time or the local timezone). |
| 863 | func ParseDTime( |
| 864 | ctx ParseTimeContext, s string, precision time.Duration, |
| 865 | ) (_ *DTime, dependsOnContext bool, _ error) { |
| 866 | now := relativeParseTime(ctx) |
| 867 | |
| 868 | // Special case on 24:00 and 24:00:00 as the parser |
| 869 | // does not handle these correctly. |
| 870 | if DTimeMaxTimeRegex.MatchString(s) { |
| 871 | return MakeDTime(timeofday.Time2400), false, nil |
| 872 | } |
| 873 | |
| 874 | if strings.HasPrefix(s, LibPQTimePrefix) { |
| 875 | s = "1970-01-01" + s[len(LibPQTimePrefix):] |
| 876 | } |
| 877 | |
| 878 | t, dependsOnContext, err := pgdate.ParseTimeWithoutTimezone(now, pgdate.ParseModeYMD, s) |
| 879 | if err != nil { |
| 880 | // Build our own error message to avoid exposing the dummy date. |
| 881 | return nil, false, makeParseError(s, types.Time, nil) |
| 882 | } |
| 883 | return MakeDTime(timeofday.FromTime(t).Round(precision)), dependsOnContext, nil |
| 884 | } |
| 885 | |
| 886 | // ResolvedType implements the TypedExpr interface. |
| 887 | func (*DTime) ResolvedType() *types.T { |
no test coverage detected