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)
| 1918 | // ParseDTime parses and returns the *DTime Datum value represented by the |
| 1919 | // provided string, or an error if parsing is unsuccessful. |
| 1920 | func 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. |
| 1940 | func (*DTime) ResolvedType() *types.T { |
no test coverage detected
searching dependent graphs…