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)
| 605 | // intervalPlusNonInterval adds given interval duration to the given time.Time value. |
| 606 | // During converting interval duration to time.Duration type, it can overflow. |
| 607 | func 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 | } |
no test coverage detected