CNV_FORMATDATETMP

This procedure formats a date, specified in DATE_ARY, according to a template, specified in TMP_ARY. The template can be retrieved for any convention from the CNV_TEMPLATE procedure. It can also be created by the user. The formatted date is returned in the language specified in LANG_NAME.

Example

This example formats a date using a template provided by the calling program. The formatted date is translated into English and returned in FD_ARY. The date consists of an unabridged name of a day of the week, an abbreviated month name, a numeric day of the month, a day of the month suffix “rd”, and a numeric year.

BEGIN

 $ INCLUDE INTL="*SYMBOL/INTL/ALGOL/PROPERTIES." 10000000 - 49999999

  FILE OUT(KIND=DISK,UNITS=CHARACTERS,MYUSE=IO,FILETYPE=0,NEWFILE,
           MAXRECSIZE=80,TITLE="OUT/ALGOL/CNVFMTDATETMP.");
  DEFINE MAX_NAME_LEN        = 17#;    % Maximum length of convention
                                       % name
  EBCDIC ARRAY TMP_ARY[0:47], DATE_ARY[0:7], FD_ARY[0:44],
               LANG_NAME[0:MAX_NAME_LEN - 1];
  INTEGER FD_LEN, RESULT;

  REPLACE DATE_ARY BY "19901003";
  REPLACE TMP_ARY BY "!W!,!1N!.!DE!,!YYYY!";
  REPLACE LANG_NAME BY "ENGLISH";
  RESULT := CNV_FORMATDATETMP(DATE_ARY, TMP_ARY, LANG_NAME,
                              FD_LEN, FD_ARY);

  WRITE(OUT,<"RESULT = ",J4>,RESULT);
  IF RESULT EQL CS_DATAOKV THEN
    WRITE(OUT,<"FD_ARY = ",C45>,FD_ARY);
  CLOSE(OUT,LOCK);
END.

Output

RESULT = 1
FD_ARY = Wednesday, Oct. 3rd, 1990

In this call, the parameters have the following meanings:

DATE_ARY is an EBCDIC array passed to the procedure. It contains the date to be formatted. The date must be in the form YYYYMMDD. The fields of the array have fixed positions. Blanks or zeroes must be used in any fields that are omitted.

TMP_ARY is an EBCDIC array passed to the procedure. It contains the template used to format the date. The template must use the control characters described in the MultiLingual System Administration, Operations, and Programming Guide.

LANG_NAME is an EBCDIC array passed to the procedure. It contains the language to be used in formatting the date. Refer to the MultiLingual System Administration, Operations, and Programming Guide for information about determining the valid language names on the system on which the user program is running.

FD_LEN is an integer returned by the procedure. It contains the length of the formatted date.

FD_ARY is an EBCDIC array returned by the procedure. It contains the formatted date.

RESULT is an integer returned by the procedure. It indicates whether or not an error occurred during the execution of the procedure. An explanation of the error result values and messages can be found at the end of this section. The values returned by this procedure include:

CS_ARRAY_TOO_SMALLV (3001)

CS_BAD_YEARV (3046)

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_BAD_YEAR_YYV (3045)

CS_BAD_DATA_LENV (3002)

CS_DATAOKV (1)

CS_BADDATEINPUTV (3012)

CS_FAULTV (1001)

CS_BAD_DAYOFYEARV (3058)

CS_FIELD_TRUNCATEDV (2003)

CS_BAD_DAYV (3048)

CS_LANGUAGE_NOT_FOUNDV (2001)

CS_BAD_MONTHV (3047)

CS_MISSING_DATE_COMPONENTV (3059)

CS_BAD_TEMPCHARV (3011)

CS_MISSING_MONTH_COMPONENTV (3057)

CS_BAD_TEMPLENV (3030)

CS_SOFTERRV (1002)