現在時刻の処理
現在時刻は、最新の時点を表します。現在時刻の式には、例えば、current month、last 3 hours または next 3 hours、now、today、tomorrow、および yesterday などが含まれます。
現在時刻は、以下の方法で表すことができます。
now
ルール言語で、現在時刻は、now という用語で表される時刻です。ビジネス言語の操作の now の値の精度は、秒です。転送中にイベントが遅延した場合、イベントのタイム・スタンプが now の値よりも前になることがあります。
以下のルールは、毎週月曜日 10:00 AM にリマインダーを送信します。
if
now is on Monday at 10:00:00 AM
then
print "send weekly reminder.";
now は、イベントのタイム・スタンプから設定されます (秒に切り捨て)。ただし、イベントの到着順序が入れ替わった場合、now が時間を後戻りすることはありません。例えば、タイム・スタンプが今日の 11:00:00 AM のイベントが到着し、その後タイム・スタンプが今日の 10:55:00 AM のイベントが到着した場合、両イベントの処理時に、now は 11:00:00 AM になります。必要に応じて、ルールにより、イベントのタイム・スタンプが now より前かどうかを検査することで、イベントが転送中に遅延したことを検出できます。
if
now is on Monday at 10:00:00 AM
このルールは、毎週月曜日の 10:00:00 AM にできる限り近い時間に処理され、now は、当該ルールの処理時にちょうど 10:00:00 AM に設定されます。現在の期間
現在時刻を含む、時間目盛りの期間を参照するために、ルールは、the current year および the current month などの式を使用することができます。これらの式は、the calendar year of now、および the calendar month of now と同等です。
以下のルールは、今月中の空港の閉鎖についてチェックします。
when an airport closed event occurs
if
the number of airport closed events during the current month is more than 4
then
print “More than 4 airports have been closed this month.”;
前の期間および次の期間
現在時刻より前または後の期間を参照するには、the last period of 演算子と the next period of 演算子を使用します。これらの式は両方とも、現在時刻 now を参照しますが、含んではいません。
the last period of 7 days は、the period of 7 days before now に対応します。
以下のルールは、過去 3 カ月の間に 5 本以上の遅延フライトがある場合に警告を送信します。when 節で処理される flight delayed event は、この期間には含まれないため、カウントに含まれません。このルールの条件は、6 番目のイベントを受信した時に true になります。
when a flight delayed event occurs
if
the number of flight delayed events during the last period of 3 months is at least 5
then
print "Warning: the number of delayed flights in the past 3 months is at least 5." ;
以下のルールは、遅延フライト・イベント後の、次の 30 分以内に他のフライトが計画されているかどうかをチェックします。
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 during the next period of 30 minutes,
then
print "The customer has less than 30 minutes to get to the next flight.";
yesterday、today、tomorrow
- today は、the calendar day of now 式に対応します。
- yesterday は、today の 1 日前の期間に対応します。
- tomorrow は、today の 1 日後の期間に対応します。
以下のルールは、夜間フライトについてチェックします。
if
the scheduled departure time of 'the flight' is during yesterday
and the scheduled arrival time of 'the flight' is during today
then
print "Overnight flight." ;