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, )
| 1014 | // The dependsOnContext return value indicates if we had to consult the |
| 1015 | // ParseTimeContext (either for the time or the local timezone). |
| 1016 | func 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. |
| 1035 | func (d *DTimestamp) Round(precision time.Duration) (*DTimestamp, error) { |
no test coverage detected