The dateTimeLib.intervalValue() system
function
returns an INTERVAL value from a source string. EGL maintains this
function
for compatibility with earlier versions. New code can simply assign
the string
to the TIME variable.
The function expects an input string containing
six digits. The first four
digits represent the number of years in the interval, and the last
two represent
the number of months. If you want to specify a pattern other than
"yyyyMM",
use dateTimeLib.intervalValueWithPattern().
To convert the string value to an INTERVAL value, EGL uses the
following
methods in order:
- EGL attempts to parse the text into an INTERVAL
value using the "yyyyMM"
mask. If EGL cannot parse the text in this way, it tries the next
method.
- EGL parses the text into two groups of digits: four
for the year and two
for the month, using non-digit characters as separators between the
digits:
- EGL first ignores any non-digit characters at the beginning
of the text.
- EGL then uses the following digit characters
for the years field of the
INTERVAL value. EGL stops adding digits to this field when it reaches
a non-digit
character in the text or when it reaches four digits.
- EGL
skips any following non-digit characters.
- EGL then repeats
Steps b and c for the two digits each in the month field.
- After
all the fields have been filled, any remaining digit or non-digit
characters in the text are ignored.
If this process does
not produce at least one digit for each field in
the pattern, the process fails and throws a TypeCastException.For
examples
of this parsing process, see dateValue().