From 67cf2fa60461668b48ccfcc27ebd70efb43722bc Mon Sep 17 00:00:00 2001 From: Faith Chikwekwe Date: Fri, 28 Jul 2023 12:57:44 -0400 Subject: [PATCH 1/2] Update pkg/ottl/README.md Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> --- pkg/ottl/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ottl/README.md b/pkg/ottl/README.md index 1761db5aeef5..65e33189a77e 100644 --- a/pkg/ottl/README.md +++ b/pkg/ottl/README.md @@ -172,8 +172,8 @@ When defining an OTTL function, if the function needs to take an Enum then the f Math Expressions represent arithmetic calculations. They support `+`, `-`, `*`, and `/`, along with `()` for grouping. -Math Expressions currently support `int64` and`float64`. -Math Expressions also support `time.Time` and `time.Duration`, but only with `+` and `-` and only using the following rules: +Math Expressions currently support `int64`, `float64`, `time.Time` and `time.Duration`. +For `time.Time` and `time.Duration`, only `+` and `-` are supported with the following rules: - A `time.Time` `-` a `time.Time` yields a `time.Duration`. - A `time.Duration` `+` a `time.Time` yields a `time.Time`. - A `time.Time` `-` a `time.Duration` yields a `time.Time`. From ac8cd420ca52bfe7906ca15445482cdef4b4dcb6 Mon Sep 17 00:00:00 2001 From: Faith Chikwekwe Date: Fri, 28 Jul 2023 12:57:56 -0400 Subject: [PATCH 2/2] Update pkg/ottl/math.go Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> --- pkg/ottl/math.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ottl/math.go b/pkg/ottl/math.go index 9adbd8499256..897ed22c3ade 100644 --- a/pkg/ottl/math.go +++ b/pkg/ottl/math.go @@ -130,7 +130,7 @@ func performOpTime(x time.Time, y any, op mathOp) (any, error) { result := x.Add(-1 * newY) return result, nil default: - return nil, fmt.Errorf("time.Time must be subtracted from time.Time or time.Duration; found %v instead", y) + return nil, fmt.Errorf("time.Time or time.Duration must be subtracted from time.Time; found %v instead", y) } } return nil, fmt.Errorf("only addition and subtraction supported for time.Time and time.Duration")