periodlength

Calcule la quantité d'unités temporelles entre deux dates.

L'une des unités de temps suivantes doit être spécifiée :

L'expression periodlength doit également indiquer si la date de fin de la période est inclusive ou exclusive ou la date de fin (la période est toujours inclusive de la date de début).

Le calcul de la période est toujours arrondi à l'entier le plus proche.

<?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 n'était pas une année bissextile -->
    <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>
        <!-- démarre et se termine sur le même jour = 1 jour -->
        <periodlength endDateInclusion="inclusive" unit="days">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="firstDayOfJanuary1970"/>
        </periodlength>
      </derivation>
    </Attribute>

    <Attribute name="sameDay_LengthInWeeks">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- démarre et se termine sur le même jour = 0 semaine-->
        <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 jours -->
        <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 an (pratiquement 1 an, à un jour près) -->
        <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 an (exactement) -->
        <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 an (exactement) -->
        <periodlength endDateInclusion="exclusive" unit="years">
          <reference attribute="firstDayOfJanuary1970"/>
          <reference attribute="firstDayOfJanuary1971"/>
        </periodlength>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>