Comparing a time point and a period

Check that a time point is before, after, or during a time period. Check that a time period includes a time point, or starts and ends at a particular time point.

Time point compared to a period

Use the following operators to compare a time point and a time period:
  • before

    A time point is before a time period if this time point is earlier than the start of the period.

  • after

    A time point is after a time period if this time point is later or at the same instant as the end of the period.

  • during

    A time point is during a time period if it is later or at the same instant as the start time, and earlier than the end time.

A time point can be compared with the start and the end of the period. For example, each purchase event is before the end of 'the trip'.

You can also compare a time point to a calendar period, for example:

the departure time of 'the flight' is during the calendar year 2012

the departure time of 'the flight' is after the calendar month February 2007

the departure time of 'the flight' is before today

In the following rule, the flight period is defined by the scheduled departure date and arrival date.

when a purchase event occurs
definitions
    set 'the flight' to a flight in the flights of 'the customer';
    set 'the flight period' to the period between the scheduled departure time of 'the flight' and the scheduled arrival time of 'the flight';
if
    this purchase event is during 'the flight period'
then
    print "purchase on board";

Period compared to, or including a time point

Use the following operators to compare a period and a time point:
  • before
  • after
  • includes

    For example, the period of two hours after the start of 'the business trip' includes 'the purchase event'

  • starts at
  • ends at

    For example, 'the exceptional promotion period' ends at 'the purchase event'

The transit rule can be expressed by comparing the time period to the time point. This rule uses the includes operator.

when a flight arrival event occurs
if 
 there is at least one flight in the flights of 'the customer'
	where the period of 1 hour after this flight arrival event includes the scheduled departure time of this flight,
then 
	print "less than 1 hour of transit time.";

Time point within a period

A time point can be within a period that is defined by a duration before or after a time point.

For example, 'the purchase event' is within 2 hours after the start of 'the business trip'. This expression is equivalent to 'the purchase event' is during the period of 2 hours after the start of 'the business trip'.

The following rule checks whether there is another flight departure in the hour after the arrival of the current flight.

when a flight arrival event occurs
if
    there is at least one flight in the flights of 'the customer'
        where the scheduled departure time of this flight is within 1 hour after the scheduled arrival time of this flight,
then
    print "less than 1 hour of transit time.";

Time point compared to start and end times

The language contains several operators for testing if a time point is between a start and an end time. A comparison can include or exclude the start and end times.

Use the following operators to check a time point between a start and an end time:

  • before or after

    For example, 'the purchase event' is after the start of 'the business trip' and before the arrival time of 'the flight'.

  • on or before or on or after

    For example, 'the purchase event' is on or after the start of 'the business trip' and before the arrival time of 'the flight'