持続期間の処理

持続期間は、2 つの時刻の間隔です。持続期間は、2 つのポイント間の距離によって表すことができます。あるいは、six months などの数値と単位によって定義することができます。

持続期間には、絶対持続期間とカレンダー持続期間があります。

絶対持続期間

絶対持続期間は、2 つの時刻の間隔を測定します。絶対持続期間は、以下のようなさまざまな方法で表すことができます。
  • 2 つの特定の時点について計算される持続期間: the duration between <a date> and <a date>。

    例えば、the duration between the departure time of 'the flight' and the arrival time of 'the flight' となります。

  • 期間の持続期間: the duration of <a time period>。

    例えば、the duration of 'the flight period' となります。

  • オブジェクトの属性としての持続期間。例えば、the planned duration of 'the flight' となります。

    ビジネス・モデル定義で、タイプ (duration) をイベントまたはエンティティーの属性に設定することができます。例えば、.bmd ファイルで、flight エンティティーに対して、a flight has a planned duration (duration) というステートメントを作成します。

絶対持続期間は、次のように特定の時間単位に変換できます。the planned duration of 'the flight' in hours。この演算子は整数を返します。year および month は不定期な時間単位のため、これらの変換には含まれません。

以下のルールは、フライトの持続期間が予期されている持続期間より長いかどうかをチェックします。

when a flight arrival event occurs
definitions
    set 'the flight departure event' to a flight departure event;
    set 'the actual duration' to the duration between 'the flight departure event' and this flight arrival event;
if
    'the actual duration' is longer than the planned duration of 'the flight'
then
    print "The duration of the flight is longer than expected";

カレンダー持続期間

カレンダー持続期間は、時間の単位によって表されます。これらの単位は、year、month、week、day、hour、minute、および second です。

ルールで、プレースホルダー <calendar duration> を、数値と単位の名前、またはこれらの組み合わせに置き換えます。

  • 数値と単位の名前。例えば、5 days before 'the flight departure event'。
  • 数値と時間単位の組み合わせ。例えば、1 week 5 days 2 hours before 'the flight departure event'。

    異なる単位にわたる持続期間は、組み合わされて新しい持続期間を形成します。これらの単位は、降順で順序付けされ、処理されます。例えば、1 year 1 month 1 day または 7 days 3 hours。

以下のルールは、1 時間 30 分のカレンダー持続期間を使用して、フライト出発の遅延をチェックします。

when a flight departure event occurs
if
    this flight departure event is after 1 hour 30 minutes after the scheduled departure time of 'the flight'
then
    print "The departure of the flight was delayed by at least an hour and a half.";