You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to facilitate contexts returning time fields as time.Time we need to be able to compare time.Time values in boolean expressions. Although not supported by the grammar as literals, OTTL should allow working with these types.
When comparing time.Time fields, the following rules should be followed:
time.Equal should be used to check if 2 times are equal.
time.Before should be used to check if 1 time is earlier than another.
time.After should be used to check if 1 time is later than another.
Given 2 times, A and B:
A < B is true if and only if A.Before(B) is true.
A <= B is true if A.Before(B) is true OR A.Equal(B) is true.
A > B is true if and only if A.After(B) is true.
A >= B is true if A.After(B) is true OR A.Equal(B) is true.
A == B is true if and only if A.Equal(B) is true.
A != B is true if and only if A.Equal(B) is false.
If either A or B is not a time, the comparison is false.
The text was updated successfully, but these errors were encountered:
TylerHelmuth
changed the title
OTTL Boolean expressions are update to be able to handle comparing time.Time types
[pkg/ottl] Boolean expressions are update to be able to handle comparing time.Time types
May 16, 2023
Description: Allows time comparison by enabling boolean behavior for
time objects.
Link to tracking Issue: Closes#22008
Testing: Unit tests
Documentation:
---------
Co-authored-by: Tyler Helmuth <[email protected]>
In order to facilitate contexts returning time fields as
time.Time
we need to be able to comparetime.Time
values in boolean expressions. Although not supported by the grammar as literals, OTTL should allow working with these types.When comparing
time.Time
fields, the following rules should be followed:time.Equal
should be used to check if 2 times are equal.time.Before
should be used to check if 1 time is earlier than another.time.After
should be used to check if 1 time is later than another.Given 2 times, A and B:
A < B
is true if and only ifA.Before(B)
is true.A <= B
is true ifA.Before(B)
is true ORA.Equal(B)
is true.A > B
is true if and only ifA.After(B)
is true.A >= B
is true ifA.After(B)
is true ORA.Equal(B)
is true.A == B
is true if and only ifA.Equal(B)
is true.A != B
is true if and only ifA.Equal(B)
is false.If either A or B is not a time, the comparison is false.
The text was updated successfully, but these errors were encountered: