CNV_SYSTEMDATETIMETMP

This procedure obtains the system date and time and formats them according to a template and language supplied by the program. The template can be retrieved for any convention from the CNV_TEMPLATE procedure. It can also be created by the user. The system obtains the date and time from a single TIME(206) function call to avoid the possibility of splitting the date and time across a day boundary.

Example

This example formats system date and time according to a template provided by the calling program in TEMP_ARY. The formatted date and time are translated to English and returned in SDT_ARY. DTEMP_LEN is set to the length of date template in TEMP_ARY.

	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/CNVSYSDATETIMETMP.");
  DEFINE MAX_NAME_LEN        = 17#;    % Maximum length of convention
                                       % name
  EBCDIC ARRAY TEMP_ARY[0:47], SDT_ARY[0:59],
               LANG_NAME[0:MAX_NAME_LEN - 1];
  INTEGER DATE_LEN, DTEMP_LEN, RESULT, SDT_LEN;
  POINTER PTR;

  REPLACE PTR:TEMP_ARY BY "!W!,!N!!D!,!YYYY! ";  % Long date template
  DTEMP_LEN := OFFSET(PTR);
  REPLACE PTR BY "!0T!:!0M!:!0S!";  % Numeric time template
  REPLACE LANG_NAME BY "ENGLISH";
  RESULT := CNV_SYSTEMDATETIMETMP(TEMP_ARY, LANG_NAME, DTEMP_LEN,
                                  DATE_LEN, SDT_LEN, SDT_ARY);
  WRITE(OUT,<"RESULT  = ",J4>,RESULT);
  
IF RESULT EQL CS_DATAOKV THEN
    WRITE(OUT,<"SDT_ARY = ",C60>,SDT_ARY);
  CLOSE(OUT,LOCK);
END.

Output

RESULT  = 1
SDT_ARY = Friday, November 9, 1990 10:31:44

In this call, the parameters have the following meanings:

TEMP_ARY is an EBCDIC array passed to the procedure. It contains the template, left justified. If both date and time templates are present, the date template must appear first.

LANG_NAME is an EBCDIC array passed to the procedure. It contains the language to be used in formatting the date and time value. If this parameter contains all blanks or zeros, the procedure uses the hierarchy to determine the language to be used. Refer to the MultiLingual System Administration, Operations, and Programming Guide for information about determining the valid language names on the system being used and the explanation of the hierarchy.

DTEMP_LEN is an integer passed to the procedure. It specifies the length of the date template in TEMP_ARY. If DTEMP_LEN is 0 (zero), there is no date template in TEMP_ARY. If both a date and time template are specified, then the date template must appear first in TEMP_ARY. The date and time are formatted if both date and time templates are present. The date is formatted if only the date template is present, and the time is formatted if only the time template is present.

DATE_LEN is an integer returned by the procedure that contains the length of the formatted date portion of date and time. This parameter is 0 (zero) if there is no formatted date in the output. If both the date and time are presented in the output, the formatted date is separated from the formatted time by a blank. The extra character is reflected in the length of the formatted date.

SDT_LEN is an integer returned by the procedure that contains the length of the formatted date and time.

SDT_ARY is an EBCDIC array returned by the procedure. It contains the formatted date and/or time.

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_12HOURV (3052)

CS_BAD_ARRAY_DESCRIPTIONV (3000)

CS_BAD_YEARV (3046)

CS_BAD_DATA_LENV (3002)

CS_BAD_YEAR_YYV (3045)

CS_BAD_DAYOFYEARV (3058)

CS_DATAOKV (1)

CS_BAD_DAYV (3048)

CS_FAULTV (1001)

CS_BAD_HOURV (3051)

CS_FIELD_TRUNCATEDV (2003)

CS_BAD_MINUTEV (3053)

CS_LANGUAGE_NOT_FOUNDV (2001)

CS_BAD_MONTHV (3047)

CS_MISSING_DATE_COMPONENTV (3059)

CS_BAD_PSECONDV (3055)

CS_MISSING_MONTH_COMPONENTV (3057)

CS_BAD_SECONDV (3054)

CS_SOFTERRV (1002)

CS_BAD_TEMPCHARV (3011)