To make sure Trepresents the time of validation and not the time of parsing the syntax,
Valang parses date literals every time the validation constraint is executed. These semantics
make sure Tis always now.
The Valang date parser supports two date operator types: shift operators and incremental
operators.
Suppose we want to test whether the order timestamp property value is today (see Listing
9-13). To achieve this we have to create two limits: the start of the day and the end of the day.
The date parser notation to create these two timestamps is [T<d]and [T>d]. The shift-down
(<) and shift-up (>) operators take a one-character argument to determine how far back or
forth to shift. Each shift operator affects a specific part of the timestamp. The dor day operator
affects the time part of the timestamp. It resets the time to 00:00:00.000 for the shift-down
operator and to 23:59:59.999 for the shift-up operator.
Listing 9-13.Testing Whether a Date Value Is Today
{ order.timestamp :
? between [T<d] and [T>d] :
'' : 'order.timestamp.not_today' :? }
Valang supports the shift operators shown in Table 9-2.
Table 9-2.Shift Operators for Dates in Valang
Notation Description
>s Shifts second to end of second (999 milliseconds).
<s Shifts second to start of second (0 milliseconds).
>m Shifts minute to end of minute (59 seconds, 999 milliseconds).
<m Shifts minute to start of minute (0 seconds, 0 milliseconds).
>H Shifts hour to end of hour (59 minutes, 59 seconds, 999 milliseconds).
<H Shifts hour to start of hour (0 minutes, 0 seconds, 0 milliseconds).
>d Shifts day to end of day (23 hours, 59 minutes, 59 seconds, 999 milliseconds).
<d Shifts day to start of day (0 hours, 0 minutes, 0 seconds, 0 milliseconds).
>w Shifts date to the end of the current week (next Sunday, 23 hours, 59 minutes, 59
seconds, 999 milliseconds).
<w Shifts date to start of current week (previous Monday, 0 hours, 0 minutes, 0 seconds,
0 milliseconds).
>M Shifts date to end of current month (last day of month, 23 hours, 59 minutes,
59 seconds, 999 milliseconds).
<M Shifts date to start of current month (first day of month, 0 hours, 0 minutes,
0 seconds, 0 milliseconds).
>y Shifts date to end of year (last day of year, 23 hours, 59 minutes, 59 seconds,
999 milliseconds).
<y Shifts date to start of year (first day of year, 0 hours, 0 minutes, 0 seconds,
0 milliseconds).
272 CHAPTER 9 ■VALIDATION