MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ParseTimestamp

Function ParseTimestamp

postgres/parser/pgdate/parsing.go:212–229  ·  view source on GitHub ↗

ParseTimestamp converts a string into a timestamp. The dependsOnContext return value indicates if we had to consult the given `now` value (either for the time or the local timezone).

(
	now time.Time, mode ParseMode, s string,
)

Source from the content-addressed store, hash-verified

210// The dependsOnContext return value indicates if we had to consult the given
211// `now` value (either for the time or the local timezone).
212func ParseTimestamp(
213 now time.Time, mode ParseMode, s string,
214) (_ time.Time, dependsOnContext bool, _ error) {
215 fe := fieldExtract{
216 mode: mode,
217 currentTime: now,
218 // A timestamp only actually needs a date component; the time
219 // would be midnight.
220 required: dateRequiredFields,
221 wanted: dateTimeFields,
222 }
223
224 if err := fe.Extract(s); err != nil {
225 return TimeEpoch, false, parseError(err, "timestamp", s)
226 }
227 res := fe.MakeTimestamp()
228 return res, fe.currentTimeUsed, nil
229}
230
231// ParseTimestampWithoutTimezone converts a string into a timestamp, stripping
232// away any timezone information. Any specified timezone is inconsequential. The

Callers 3

ParseDTimestampTZFunction · 0.92
ParseTimeTZFunction · 0.92
TestParseTimestampFunction · 0.70

Calls 3

ExtractMethod · 0.95
MakeTimestampMethod · 0.95
parseErrorFunction · 0.85

Tested by 1

TestParseTimestampFunction · 0.56