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

Function intervalPlusNonInterval

server/functions/binary/plus.go:607–617  ·  view source on GitHub ↗

intervalPlusNonInterval adds given interval duration to the given time.Time value. During converting interval duration to time.Duration type, it can overflow.

(d duration.Duration, t time.Time)

Source from the content-addressed store, hash-verified

605// intervalPlusNonInterval adds given interval duration to the given time.Time value.
606// During converting interval duration to time.Duration type, it can overflow.
607func intervalPlusNonInterval(d duration.Duration, t time.Time) (time.Time, error) {
608 seconds, ok := d.AsInt64()
609 if !ok {
610 return time.Time{}, errors.Errorf("interval overflow")
611 }
612 nanos := float64(seconds) * functions.NanosPerSec
613 if nanos > float64(math.MaxInt64) || nanos < float64(math.MinInt64) {
614 return time.Time{}, errors.Errorf("interval overflow")
615 }
616 return t.Add(time.Duration(nanos)), nil
617}

Callers 4

plus.goFile · 0.85

Calls 3

ErrorfMethod · 0.65
AsInt64Method · 0.45
AddMethod · 0.45

Tested by

no test coverage detected