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

Function rounded

postgres/parser/duration/duration.go:162–171  ·  view source on GitHub ↗

rounded returns nanos rounded to the nearest microsecond.

(nanos int64)

Source from the content-addressed store, hash-verified

160
161// rounded returns nanos rounded to the nearest microsecond.
162func rounded(nanos int64) int64 {
163 dur := time.Duration(nanos) * time.Nanosecond
164 v := dur.Round(time.Microsecond).Nanoseconds()
165 // Near the boundaries of int64 will return the argument unchanged. Check
166 // for those cases and truncate instead of round so that we never have nanos.
167 if m := v % nanosInMicro; m != 0 {
168 v -= m
169 }
170 return v
171}
172
173// Compare returns an integer representing the relative length of two Durations.
174// The result will be 0 if d==x, -1 if d < x, and +1 if d > x.

Callers 5

MakeDurationFunction · 0.85
MakeNormalizedDurationFunction · 0.85
SetNanosMethod · 0.85
roundMethod · 0.85
roundedMethod · 0.85

Calls 1

RoundMethod · 0.45

Tested by

no test coverage detected