期間の処理
期間は、開始時刻と終了時刻によって定義される時間の間隔です。期間は持続期間を持っています。持続期間は、その期間の開始時刻と終了時刻の間の距離に等しくなります。期間には、開始時刻は含まれますが、終了時刻は含まれません。
期間は、開始時刻と終了時刻、開始時刻と持続期間、または終了時刻と持続期間によって指定できます。期間は、時刻をより大きい時間目盛りに変換する時にも得られます。その場合、期間は、時刻とターゲット単位によって指定されます。
期間は、さまざまな方法で表すことができます。
カレンダー期間
- 年の期間は、calendar year という用語と、その年の数値によって指定されます。例えば、the calendar year 2011 となります。
- 月の期間は、月の名前と、年の数値によって表されます。例えば、the calendar month February 2014 となります。
- 日の期間は、標準の日付表記を使用して指定されます。例えば、the calendar day December
31, 2013 となります。
この例で、1 日の期間は 12/31/1999 00:00:00 AM に始まり、1/1/2000 00:00:00 AM に終了します。
以下のルールは、空港が 2013 年 12 月 31 日の間閉鎖しているかどうかをチェックします。このルールは、2013 年 12 月 31 日の終わりに評価されます。
if
there is at least one airport closed event
where this airport closed event is during the calendar day December 31, 2013 ,
then
print "The airport was closed on the last day of the year 2013.";
始点と終点のある期間
期間は、開始時刻と終了時刻によって指定できます。例えば、the period between the start of 'the business trip' and the end of 'the business trip' となります。
以下のルールは、フライトの間に 10 個を超える購入が行われるかどうかをチェックします。このルールは、フライト期間を、フライトの出発と到着の間の期間として定義しています。
definitions
set 'the flight period' to the period between the scheduled departure time of 'the flight' and the scheduled arrival time of 'the flight';
if
there are more than 10 purchase events
where each purchase event is during 'the flight period',
then
print "More than 10 purchases during this flight.";
始点または終点、および持続期間がある期間
期間は、開始時刻または終了時刻、および持続期間によって指定できます。例えば、the period of 7 days before 'the purchase event' となります。
- before および after は、期間の開始時刻または終了時刻を定義します。これらは、特定の時刻の前後の、当該時刻を含まない期間を指します。
例えば、the period of 3 months before May 2012 となります。
- the period of <calendar duration> before は、特定の時刻で終了する特定の持続期間の期間を定義します。
- the period of <calendar duration> after は、特定の時刻に開始される特定の持続期間の期間を定義します。例えば、the period of 4 hours after the 'the flight' arrived となります。
以下の演算子を使用して、指定された時刻に開始または終了し、特定の持続期間を持つ、指定された時刻を含む期間を定義します。
- the period of <calendar duration> starting at <a date> は、特定の時刻に開始される特定の持続期間の期間を定義します。
- the period of <calendar duration> ending at <a date> は、特定の時刻で終了する特定の持続期間の期間を定義します。例えば、the period of 4 hours ending at 'the purchase event' となります。
以下のルールは、フライトの到着 3 時間後に購入イベントがあったかどうかをチェックします。
when a flight arrival event has occurred 1 day ago
if
there is at least one purchase event
where this purchase event is during the period of 3 hours after this flight arrival event,
then
print "At least one purchase 3 hours after the arrival of the flight.";
期間は、複数の時間単位にわたるカレンダー持続期間によって指定することができます。例えば、the period of 2 months 2 weeks after the launch date of 'the product' となります。製品が 2013 年 2 月 14 日 9:00:00 AM に発売される場合、2 カ月と 2 週間の期間は 2013 年 4 月 28 日 9:00:00 AM に終了します。
期間に変換される時刻
期間は、時刻をより大きい時間目盛りに変換することにより得ることができます。例えば、 the period of 7 days before the calendar day of 'the purchase event' となります。この例で、the calendar day は、'the purchase event' 時刻を含むグレゴリオ暦の日付を参照します。