U_DCDDAT
Decode an alpha date string into its numeric components
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
xcall U_DCDDAT(status, [string], type, [D_TODAY], year, month, day)
Arguments
status
Returned with the decoding status (0 if successful, non-zero if unsuccessful). (n)
string
(optional) The string to convert to numeric form. (a)
type
The code for the type of date into which string will be converted: (n)
1 = PP/YYYY (or PP/YY if year accepts only two digits)
2 = PP/YYYY (or PP/YY if year accepts only two digits)
3 = DD/MM/YYYY (or DD/MM/YY if year accepts only two digits)
4 = DD/MM/YYYY (or DD/MM/YY if year accepts only two digits)
D_TODAY
(optional) Specifies that the date should default to today if string is passed and blank. (n)
year
Returned with the year. (n)
month
Returned with the month or period. (n)
day
Returned with the day. (n)
Discussion
U_DCDDAT decodes an alpha date string into separate numeric values for period and year (PP/YYYY), or for month, day, and year (DD/MM/YYYY).
String can consist of numbers only (up to eight digits), or it can consist of numbers separated by a delimiter. If string is not passed, the current date is returned and type is ignored.
If string is delimited,
- one non-alphanumeric delimiter must separate date components (e.g., ‘1-23-2006’).
- the month can be a three-letter abbreviation. The default is the first three letters of the English name for a month, but this can be overridden with U_MONTHS.
- the current day, month, or year is used for any missing date component. For example, if string is 10//2006 and g_date_order is 0, the current day will be used for the missing day.
If string consists only of numbers (no delimiter), string is parsed and interpreted according to the number of digits passed in string and the value passed for type, as listed in the table below.
Digits in string |
type |
Interpretation of string |
---|---|---|
1 or 2 |
1 or 2 |
String is a period in the current year. |
3 or 4 |
String is a day in the current month. |
|
3 or 4 |
1 or 2 |
If g_date_order is 0 or 1, the two lowest-order digits of string are a year in the default century, and the one or two remaining digits are the period. If g_date_order is 2, the two lower-order digits are the period, and the one or two remaining digits are the year. |
3 or 4 |
String is the month and day in the current year. The two lowest-order digits are the second component of the date, as defined by g_date_order, and the one or two remaining digits are the first component. |
|
5 or 6 |
1 or 2 |
If g_date_order is 0 or 1, the two lowest-order digits are the year, and one or two remaining digits are the period. If g_date_order is 2, the two lowest-order digits are the period, and the one or two remaining digits are the year. |
3 or 4 |
If g_date_order is 0 or 1, the two lowest-order digits are a year in the default century, the next two digits are the second component of the date (as defined by g_date_order). The one or two remaining digits are the first component of the date. If g_date_order is 2, the two lowest-order digits are the day, the next two are the month, and the one or two remaining digits are the year in the default century. |
|
7 or 8 |
1 or 2 |
Invalid (results in error). |
3 or 4 |
If g_date_order is 0 or 1, the four lowest-order digits are the year, the next two digits are the second component of the date, and the one or two remaining digits are the first date component. If g_date_order is 2, the two lowest-order digits are the day, the next two digits are the month, and the three or four remaining digits are the year. |
The default century is the century for the current system date unless a default century method has been registered (with E_METHOD), in which case the method must return the default century.
Examples
The following example decodes the date stored in date to the form DD/MM/YYYY and returns it in yr, mn, and dy. (For example, if date contains 1/30/1999, yr will be returned with 1999 (or 99 if it accepts only two digits), mn will be returned with 01, and dy will be returned with 30.) Sts will contain the decoding status.
xcall u_dcddat(sts, date, 4, , yr, mn, dy)
The next example decodes today’s date to the form DD/MM/YYYY (or DD/MM/YY if yr accepts only two digits) and returns it in yr, mn, and dy.
xcall u_dcddat(sts,, 3, D_TODAY, yr, mn, dy)