Comparing time periods
A time period can be before another period, after it, or overlap it. You can also compare the durations of two time periods.
- is before
For example, 'the exceptional promotion period' is before 'the flight period'
- is after
For example, 'the exceptional promotion period' is after 'the flight period'
- overlaps with
For example,'the exceptional promotion period' overlaps with 'the flight period'
Some cases of overlap are obtained when a period contains another period, or when a period is during another period.
- is during the same time as
This operator checks that two time periods have exactly the same start time and the same end time. For example,'the exceptional promotion period' is during the same time as 'the flight period'
A time period can also start or end at the same time as another period.
The following rule checks whether two business trips overlap:
definitions
set 'Trip1' to a trip in the trips of 'the customer';
set 'Trip2' to a trip in the trips of 'the customer';
set 'the first trip' to the period between the start of 'Trip1' and the end of 'Trip1';
set 'the second trip' to the period between the start of 'Trip2' and the end of 'Trip2';
if
'the first trip' overlaps with 'the second trip'
then
print "overbooked travel agenda";
Period shorter or longer than another period
- is shorter than and is shorter than or equal to
For example, 'the flight period' is shorter than 'the trip period'
- is longer than and is longer than or equal to
For example, 'the trip period' is longer than or equal to 'the flight period'