IBM Support

CEEDATM API CEE2527 Timestamp truncated

Troubleshooting


Problem

The Convert Seconds to Character Timestamp (CEEDATM) API formats a number representing the number of seconds since 00:00:00 14 October 1582. The output is a character string such as 1988/07/26 20:37:00.

One of the parameters in using this API which is an output_timestamp is a character string that is the result of converting input_seconds to the format specified by picture_string.

https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/apis/CEEDATM.html

ILE/C program is created that uses STGMDL (*TERASPACE).
The program is compiled to TGTRLS(V7R2M0) on V7R3, or TGTRLS(V7R3M0) or TGTRLS(V7R2M0) on V7R4. Running the program results in message CEE2527 (timestamp truncated).
 

Resolving The Problem

The C compiler currently contains a bug such that if a called function is prototyped to pass operational descriptors (ODs) on the call, the maximum length field of the OD create by the compiler is incorrect when compiling with the STGMDL(*TERASPACE) option. Note that this error does not happen when compiling with the STGMDL(*SNGLVL) option.  Because of this defect, when the NULL-terminated string is passed, even if it is an output argument, it needs to be initialized so it contains a string of maximum length.

This can best be explained with an example.  The prototype for the CEEDATM() API, as defined in header ledate.h, is:


 

 void CEEDATM( _FLOAT8 *, char *, char *, _FEEDBACK *);
  #pragma descriptor ( void CEEDATM( void, "", "", void ) )



And an example call might be:

 

 _FLOAT8 secs = <number of seconds>;
  char format[20] = “YYYY-DD-MM HH:MI:SS”;
  char timestamp[20];
  CEEDATM(&secs, format, timestamp, NULL);



The API converts the number of seconds since October 14, 1582 into the timestamp field using the given YYYY-MM-DD HH:MI:SS format.  Since the prototype includes a #pragma descriptor, the compiler will build an OD for arguments 2 and 3 and pass them to the API.  The OD is used to indicate arguments 2 and 3 are NULL-terminated strings with maximum length 20 (19 chars + 1 NULL-terminator).  The CEEDATM() API uses the OD to determine if there is enough room in the 3rd argument to hold the result.  Which, in the case above, there should be.

However, due to the compiler defect, the OD created for argument 3 indicates a maximum length of 0, not 20.  As ODs are defined on IBM i, if the maximum length in the OD is 0 for a NULL-terminated string, the maximum length is determined by scanning the string for the 1st NULL-terminator in the string.  In the code above, the timestamp argument is not initialized; therefore, it points to storage with an unknown value.  If that storage contains zeroes, CEEDATM() will determine the maximum length to be less than 20.  Anything fewer than 20 characters cannot hold the complete timestamp that uses format, so the API issues message CEE2527 (timestamp truncated).

To circumvent this, if an API is prototyped to have an OD, ensure the NULL-terminated string passed has been initialized to its maximum length.  In the case above, timestamp would need to be initialized to the format string to ensure a correct maximum length is computed.  For example:

 

 _FLOAT8 secs = <number of seconds>;
  char format[20] = “YYYY-DD-MM HH:MI:SS”;
  char timestamp[20] = “YYYY-DD-MM HH:MI:SS”;
  /* alternatively, you could code:  strcpy(timestamp, format); */
  CEEDATM(&secs, format, timestamp, NULL);



Note: This problem has been fixed in some version of the ILE/C compiler via PTFs.  These are the released compiler versions as of March 10, 2023 and the corresponding PTF numbers, if it exists.

7.5 TGTRLS(*CURRENT) Works w/o PTF
7.5 TGTRLS(*PRV) No PTF
7.5 TGTRLS(V7R3M0) No PTF
7.4 TGTRLS(*CURRENT) 5770SS1-SI76526
7.4 TGTRLS(*PRV) 5770SS1-SI79254
7.4 TGTRLS(V7R2M0) No PTF
7.3 TGTRLS(*CURRENT)
5770SS1-SI76525
7.3 TGTRLS(*PRV) No PTF
7.3 TGTRLS(V7R1M0) No PTF

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;7.4.0"}]

Document Information

Modified date:
15 March 2023

UID

ibm16962823