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

Function ParseDTimestamp

postgres/parser/sem/tree/datum.go:1016–1032  ·  view source on GitHub ↗

ParseDTimestamp parses and returns the *DTimestamp Datum value represented by the provided string in UTC, 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,
)

Source from the content-addressed store, hash-verified

1014// The dependsOnContext return value indicates if we had to consult the
1015// ParseTimeContext (either for the time or the local timezone).
1016func ParseDTimestamp(
1017 ctx ParseTimeContext, s string, precision time.Duration,
1018) (_ *DTimestamp, dependsOnContext bool, _ error) {
1019 now := relativeParseTime(ctx)
1020 t, dependsOnContext, err := pgdate.ParseTimestampWithoutTimezone(now, pgdate.ParseModeYMD, s)
1021 if err != nil {
1022 t, dependsOnContext, err = pgdate.ParseTimestampWithoutTimezone(now, pgdate.ParseModeDMY, s)
1023 if err != nil {
1024 t, dependsOnContext, err = pgdate.ParseTimestampWithoutTimezone(now, pgdate.ParseModeMDY, s)
1025 if err != nil {
1026 return nil, false, err
1027 }
1028 }
1029 }
1030 d, err := MakeDTimestamp(t, precision)
1031 return d, dependsOnContext, err
1032}
1033
1034// Round returns a new DTimestamp to the specified precision.
1035func (d *DTimestamp) Round(precision time.Duration) (*DTimestamp, error) {

Callers 2

timestamp.goFile · 0.92
ParseAndRequireStringFunction · 0.85

Calls 3

relativeParseTimeFunction · 0.85
MakeDTimestampFunction · 0.85

Tested by

no test coverage detected