A DayExpression allows to express times symbolically. The syntax of a day expression has the following informal grammar:
expression := (today|start|end|date)(+|-integer) date := yyyy-mm-dd
In words, a day expression is a keyword or a date followed by zero or more positive or negative offsets. The keywords are
today,
start and
end. To be resolved as a time index, a day expression requires a context. Possible contexts a time domain or a range. The keywords start and end can only be resolved in the context of a range. For example, the expression
end-2+1
corresponds to the upper bound of the context range, minus 1. Day expressions can be incremented without being resolved. For example, incrementing the expression
start
by 2 equals
start+2
.
The date part is a day in the standard daily domain. With the keywords start and end, and with literal dates, the offset is applied in the target domain, as given by the context argument when dates are returned. But with the keyword today, the offset is applied sometimes in the daily domain. It is applied in the daily domain only when the target domain resolution is finer than daily. This is for example useful when getting the last n days of a series with second resolution. In all other cases, the offset is applied in the target domain.
It is possible to use incomplete dates like a year without month and day, and they will be completed in the standard fashion, but offsets are only valid with complete daily dates.
A new day expression has no default value. Trying to resolve a new day expression which was never set is a bug and throws an {@link IllegalStateException}.
@author Jean-Paul Vetterli