MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / roundAndCheck

Function roundAndCheck

pkg/sql/sem/tree/datum.go:2890–2900  ·  view source on GitHub ↗

roundAndCheck rounds the given time to the specified precision and checks if the rounded time is within the supported bounds. Supported bounds: - [MinSupportedTime, MaxSupportedTime] - TimeInfinity - TimeNegativeInfinity

(t time.Time, precision time.Duration)

Source from the content-addressed store, hash-verified

2888// - TimeInfinity
2889// - TimeNegativeInfinity
2890func roundAndCheck(t time.Time, precision time.Duration) (time.Time, error) {
2891 ret := t.Round(precision)
2892 if ret.After(MaxSupportedTime) || ret.Before(MinSupportedTime) {
2893 if t == pgdate.TimeInfinity || t == pgdate.TimeNegativeInfinity {
2894 return t, nil
2895 }
2896
2897 return time.Time{}, NewTimestampExceedsBoundsError(ret)
2898 }
2899 return ret, nil
2900}
2901
2902// MakeDTimestampTZ creates a DTimestampTZ with specified precision.
2903func MakeDTimestampTZ(t time.Time, precision time.Duration) (_ *DTimestampTZ, err error) {

Callers 4

MakeDTimestampFunction · 0.85
MakeDTimestampTZFunction · 0.85
ParseTimestampTZFunction · 0.85

Calls 4

BeforeMethod · 0.80
RoundMethod · 0.45
AfterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…