## 8.3. Exemple de Expresii Bazate pe Timp

A small sample of how time based expressions can be used.

Exemplu 8.1. Adevărat dacă acum este oricând în anul 2005

```<rule id="rule1">
<date_expression id="date_expr1" start="2005-001" operation="in_range">
<duration years="1"/>
</date_expression>
</rule>```

Exemplu 8.2. Equivalent expression

```<rule id="rule2">
<date_expression id="date_expr2" operation="date_spec">
<date_spec years="2005"/>
</date_expression>
</rule>```

Exemplu 8.3. 9am-5pm, Lun-Vineri

```<rule id="rule3">
<date_expression id="date_expr3" operation="date_spec">
<date_spec hours="9-16" days="1-5"/>
</date_expression>
</rule>```

Vă rugăm să luați aminte că `16` se potrivește cu `16:59:59`, deoarece valoarea numerică (ora) încă se potrivește!

Exemplu 8.4. 9am-6pm, Lun-Vineri sau toată ziua sâmbătă

```<rule id="rule4" boolean_op="or">
<date_expression id="date_expr4-1" operation="date_spec">
<date_spec hours="9-16" days="1-5"/>
</date_expression>
<date_expression id="date_expr4-2" operation="date_spec">
<date_spec days="6"/>
</date_expression>
</rule>```

Exemplu 8.5. 9am-5pm sau 9pm-12pm, Lun-Vineri

```<rule id="rule5" boolean_op="and">
<rule id="rule5-nested1" boolean_op="or">
<date_expression id="date_expr5-1" operation="date_spec">
<date_spec hours="9-16"/>
</date_expression>
<date_expression id="date_expr5-2" operation="date_spec">
<date_spec hours="21-23"/>
</date_expression>
</rule>
<date_expression id="date_expr5-3" operation="date_spec">
<date_spec days="1-5"/>
</date_expression>
</rule>```

Exemplu 8.6. Zilele de Luni în Martie 2005

```<rule id="rule6" boolean_op="and">
<date_expression id="date_expr6-1" operation="date_spec">
<date_spec weekdays="1"/>
</date_expression>
<date_expression id="date_expr6-2" operation="in_range"
start="2005-03-01" end="2005-04-01"/>
</rule>```

Notă

Because no time is specified, 00:00:00 is implied.
This means that the range includes all of 2005-03-01 but none of 2005-04-01. You may wish to write `end="2005-03-31T23:59:59"` to avoid confusion.

Exemplu 8.7. O lună plină pe data de Vineri 13

```<rule id="rule7" boolean_op="and">
<date_expression id="date_expr7" operation="date_spec">
<date_spec weekdays="5" monthdays="13" moon="4"/>
</date_expression>
</rule>```