Comparando Períodos de Tempo

Um período pode ser anterior ou posterior a outro período, ou pode se sobrepor a ele. Também é possível comparar as durações de dois períodos.

Use os operadores a seguir para comparar a ordem de períodos:
  • for anterior a

    Por exemplo, 'the exceptional promotion period' is before 'the flight period'

  • é depois de

    Por exemplo, 'the exceptional promotion period' is after 'the flight period'

  • overlaps with

    Por exemplo, 'the exceptional promotion period' overlaps with 'the flight period'

    Alguns casos de sobreposição ocorrem quando um período contém outro período, ou quando um período ocorre durante outro período.

  • is during the same time as

    Esse operador verifica se dois períodos têm exatamente o mesmo horário de início e o mesmo horário de encerramento. Por exemplo, 'the exceptional promotion period' is during the same time as 'the flight period'

Um período também pode começar ou terminar ao mesmo tempo que outro período.

A regra a seguir verifica se duas viagens de negócios se sobrepõem:

definições
    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';
se
    'the first trip' overlaps with 'the second trip'
então
    print "overbooked travel agenda";

Período menor ou maior do que outro período

Use os operadores a seguir para verificar a duração de um período em comparação a outro período:
  • is shorter than e is shorter than or equal to

    Por exemplo, 'the flight period' is shorter than 'the trip period'

  • is longer than e is longer than or equal to

    Por exemplo, 'the trip period' is longer than or equal to 'the flight period'