カレンダー期間の比較

カレンダー期間は、年、月、週、日、および時刻を含む時間単位に基づいています。例えば、2 つの時刻が同じカレンダー期間に含まれていることやイベントが特定の曜日または時刻に発生することを確認できます。

以下の演算子を使用して、2 つの時刻のカレンダー期間を比較します。

  • is in the same calendar year as

    月、週、および日に同様の演算子が使用可能です。

    例えば、the departure time of 'the flight' is in the same calendar month as the start of 'the business trip' などとなります。

  • is in the same hour as

    分および秒でも同様の演算子が使用可能です。

  • is before または is after

    例えば、the calendar year of the departure time of 'the flight' is after the calendar year of the start of 'the business trip' などとなります。

  • is during

    例えば、the scheduled departure time of 'the flight' is during the calendar year 2013 などとなります。

  • is during the same time as

    この演算子は、2 つの期間が同じインスタンスで開始され、同じインスタンスで終了することを確認します。例えば、the calendar year of the scheduled departure time of 'the flight' is during the same time as the calendar year 2013 などとなります。

以下のルールは、フライトの出発と同じ日に、空港が閉鎖しているかどうかをチェックします。フライトの出発が 2014 年 2 月 11 日の場合、このルールは、空港閉鎖イベントが 2014 年 2 月 11 日にも発生することをチェックします。

when an airport closed event occurs
definitions
    set 'the flight' to a flight in the flights of 'the airport';
if
    this airport closed event is on the same calendar day as the scheduled departure time of 'the flight' 
then
    print "The departure airport is closed on the day of the flight.";

以下のルールは、旅行中の毎日の支出が、指定された金額を超えているかどうかを判別します。旅行の初日と最終日の間に行われた購入は考慮されません。

definitions
  set 'the trip' to a trip in the trips of 'the customer'; 
  set 'on-trip purchases' to all purchase events where
    the calendar day of each purchase event is after the start of 'the trip' 
      and
    the calendar day of each purchase event is before the end of 'the trip';
if the total amount of 'on-trip purchases'/ 
   the duration between the start of 'the trip' and the end of 'the trip' in days    
   is more than 1000
then print "Average spending per day is high";

曜日

以下は、週末の間に行われた買い物と、平日の間に行われた買い物を比較します。
definitions
    set 'purchases last 6 months' to all purchase events
        where each purchase event is during the last period of 6 months;
    set 'workweek purchases' to all purchase events in 'purchases last 6 months'
        where the day of week of each purchase event is after or the same as Monday
        and the day of week of each purchase event is before or the same as Friday;
    set 'weekend purchases' to all purchase events in 'purchases last 6 months'
        where the day of week of each purchase event is before Monday
        and the day of week of each purchase event is after Friday;
if
    the total amount of 'weekend purchases' is more than the total amount of 'workweek purchases'
then
    print "Spending is higher at weekends.";

以下のルールは、火曜日に発生する機内での購入に特典を提供します。

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';
    set 'purchase on board' to a purchase event
        where this purchase event is during 'the flight period';
if
    'purchase on board' is on Tuesday
then
    print "apply special Tuesday discount for on-board purchases.";

時刻

時刻は、通常の時間表記の時、分、および秒で指定されます。例えば、11:59:59 PM。

以下のルールは、過去 6 カ月間の午前中のフライトの数と午後のフライトの数を比較します。

definitions
    set 'flights last six months' to all flights in the flights of 'the customer'
        where the scheduled departure time of each flight is during the last period of 6 months;
    set 'morning flights' to all flights in 'flights last six months'
        where the time of day of the scheduled departure time of each flight is before 12:00:00 PM;
    set 'afternoon flights' to all flights in 'flights last six months'
        where the time of day of the scheduled departure time of each flight is after or the same as 12:00:00 PM;
if
    the number of flights in 'morning flights' is more than the number of flights in 'afternoon flights'
then
    print "more morning flights than afternoon flights.";