Rich UI supports a subset of EGL formatting capabilities for Rich
UI dates, times, and timestamps; however, intervals are not supported.
Assigning a string to a date, time, or timestamp
Rich
UI follows the EGL rules for assigning a string to a variable of type
DATE, TIME, or TIMESTAMP. In particular, the following default formats
are in use:
- For date variables, strLib.defaultDateFormat
- For time variables, strLib.defaultTimeFormat
- For timestamp variables, strLib.defaultTimestampFormat
The following code assigns a string to a date field:
strLib.defaultDateFormat = "yyyy/MM/dd";
d date = "2008/04/08";
EGL is forgiving; for example,
when one separator is substituted for another:
strLib.defaultDateFormat = "yyyy/MM/dd";
d date = "2008-04-08";
In a second example of forgiveness,
you can omit the separators entirely:
strLib.defaultDateFormat = "yyyy/MM/dd";
myDate date = "20100412";
Assigning a date, time, or timestamp to a string
Here
are the rules for assigning time-related variables to strings:
- To assign a date variable to a string, use strLib.formatDate.
In
Rich UI, only the following formatting symbols are valid:
- yyyy for the 4-digit year
- yy for the 2-digit year
- MM for the 2-digit month
- dd for the 2-digit day
- separators such as hyphens, slashes, and blanks
You can set the build descriptor option formatDate,
which provides a default for the strLib.formatDate.
- To assign a time variable to a string, use strLib.formatTime.
In
Rich UI, only the following formatting symbols are valid:
- HH for the 2-digit hour (0 to 23) in military time
- hh for the 2-digit hour (1 to 12)
- mm for the 2-digit minute in the hour
- ss for the 2-digit second in minute
- a for AM or PM
- separators such as hyphens, slashes, and blanks
You can set the build descriptor option formatTime,
which provides a default for the strLib.formatTime.
- To assign a timestamp to a string, use strLib.formatTimestamp.
In
Rich UI, only the following formatting symbols are valid:
- HH for the 2-digit hour (0 to 23) in military time
- hh for the 2-digit hour (1 to 12)
- mm for the 2-digit minute in the hour
- ss for the 2-digit second in the minute
- SSSSSS for a fractional second; specifically, a 3-digit millisecond
followed by three zeros as a result of restrictions in JavaScript
- a for AM or PM
- separators such as hyphens, slashes, and blanks
Note that the character for fractional seconds is S for strLib.formatTimestamp,
but is f in the mask used at timestamp declaration.
You can
set the build descriptor option formatTimestamp, which provides
a default for the strLib.formatTimestamp.
If a date is assigned directly to a string (as shown in
the previous section), the string is formatted in accordance with
the default format. For example, consider the following code:
strLib.defaultDateFormat = "yyyy/MM/dd";
t date = "2010-04-12";
myString STRING = date;
The value of myString is
"2010/04/12".