Rich UI supports a subset of EGL formatting capabilities
for Rich UI dates, times, and timestamps; however, it does not support
intervals.
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, it uses the following default
formats:
- 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";
You can substitute one separator
for another:
strLib.defaultDateFormat = "yyyy/MM/dd";
d date = "2008-04-08";
You can also omit the separators
entirely:
strLib.defaultDateFormat = "yyyy/MM/dd";
myDate date = "20100412";
Assigning a date, time, or timestamp to a string
When
you assign time-related variables to strings, remember these rules:
- To assign a date variable to a string, use strLib.formatDate.
In
Rich UI, 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 formatDate build
descriptor option, which provides a default for the strLib.formatDate.
- To assign a time variable to a string, use strLib.formatTime.
In
Rich UI, 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 formatTime build
descriptor option, which provides a default for the strLib.formatTime.
- To assign a timestamp to a string, use strLib.formatTimestamp.
In
Rich UI, 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: The character for fractional seconds is S for strLib.formatTimestamp,
but is f in the mask that is used at timestamp declaration.
You
can set the formatTimestamp build descriptor
option, 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:
strLib.defaultDateFormat = "yyyy/MM/dd";
t date = "2010-04-12";
myString STRING = date;
The value of myString is "2010/04/12".