Comparing a time point and a duration
Compare a time point and a duration to test that something happens at a specific moment before or after a time point.
Use the following operators to compare a time point and a duration.
- <duration> before <date>
- <duration> after <date>
A time point can be compared to a duration in a regular time scale.
For example, the time point that is exactly seven days before the
time of the purchase event can be expressed in one of the following
ways:
- 7 days before 'the purchase event'
- 1 week before 'the purchase event'
A time point can be compared to a duration in an irregular time scale. For example, 3 months before the launch date of 'the product'. If the product is launched on February 14th, 2013, this rule returns November 14th, 2012.
You can also subtract or add more complex forms of calendar duration. For example, 2 months 1 week 2 days before the launch date of 'the product'
The following rule checks whether a purchase event happens more than 2 hours after the departure of the flight.
when a purchase event occurs
definitions
set 'the departure time' to a flight departure event;
if
this purchase event is after 2 hours after 'the departure time'
then
print "A passenger made a purchase more than 2 hours after the flight departure.";
A time point can also be defined by a time interval to another time point, which is specified in an absolute duration.