periodlength

Dieser Ausdruck berechnet die Menge der Zeiteinheiten zwischen zwei Datumsangaben.

Es muss eine der folgenden Zeiteinheiten angegeben werden:

Der Ausdruck periodlength muss außerdem angeben, ob der Zeitraum das Enddatum einschließen soll (inclusive) oder ausschließen soll (exclusive). Das Startdatum ist im Zeitraum immer eingeschlossen.

Die Berechnung für die Länge des Zeitraums wird stets auf die nächste ganze Zahl abgerundet.

<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_periodlength"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">
  <Class name="PeriodLengthExampleClass">

    <!-- NB 1970 was not a leap year -->
    <Attribute name="firstDayOfJanuary1970">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <Date value="1970-01-01"/>
      </derivation>
    </Attribute>

    <Attribute name="lastDayOfDecember1970">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <Date value="1970-12-31"/>
      </derivation>
    </Attribute>

    <Attribute name="firstDayOfJanuary1971">
      <type>
        <javaclass name="curam.util.type.Date"/>
      </type>
      <derivation>
        <Date value="1971-01-01"/>
      </derivation>
    </Attribute>

    <Attribute name="sameDay_LengthInDays">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- starts and ends on the same day = 1 day -->
        <periodlength endDateInclusion="inclusive" unit="days">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="firstDayOfJanuary1970"/>
        </periodlength>
      </derivation>
    </Attribute>

    <Attribute name="sameDay_LengthInWeeks">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- starts and ends on the same day = 0 weeks-->
        <periodlength endDateInclusion="exclusive" unit="weeks">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="firstDayOfJanuary1970"/>
        </periodlength>
      </derivation>
    </Attribute>

    <Attribute name="januaryToDecember_LengthInDays">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- 365 days -->
        <periodlength endDateInclusion="inclusive" unit="days">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="lastDayOfDecember1970"/>
        </periodlength>
      </derivation>
    </Attribute>

    <Attribute name="januaryToDecember_LengthInYearsExclusive">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- 0 years (nearly 1 year, but just 1 day short) -->
        <periodlength endDateInclusion="exclusive" unit="years">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="lastDayOfDecember1970"/>
        </periodlength>
      </derivation>
    </Attribute>

    <Attribute name="januaryToDecember_LengthInYearsInclusive">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- 1 year (exactly) -->
        <periodlength endDateInclusion="inclusive" unit="years">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="lastDayOfDecember1970"/>
        </periodlength>
      </derivation>
    </Attribute>


    <Attribute name="januaryToJanuary_LengthInYearsExclusive">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- 1 year (exactly) -->
        <periodlength endDateInclusion="exclusive" unit="years">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="firstDayOfJanuary1971"/>
        </periodlength>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>