C Examples: DbiTimeStampDecode

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiTimeStampDecode

Return to chapter overview

Decode a TimeStamp variable into a string including all information.

This example uses the following input:
         fDbiTimeStampDecode(TS, Buffer);

DBIResult fDbiTimeStampDecode(TIMESTAMP TS, pCHAR TSStr)

{

   DBIResult   rslt;

   DBIDATE     Date;

   TIME        Time;

   UINT16      h, m, ms, M, D;

   INT16       Y;

   CHAR        AMPM[3] = "AM";

 

   rslt = Chk(DbiTimeStampDecode(TS, &Date, &Time));

   if (rslt != DBIERR_NONE)

      return rslt;

 

   rslt = Chk(DbiTimeDecode(Time, &h, &m, &ms));

   if (rslt != DBIERR_NONE)

      return rslt;

 

   rslt = Chk(DbiDateDecode(Date, &M, &D, &Y));

   if (rslt != DBIERR_NONE)

      return rslt;

 

   if (h > 12)

   {

      strcpy(AMPM, "PM");

      h -= (UINT16)12;

   }

 

   wsprintf(TSStr, "%d:%d:%d %s, %d/%d/%d", h, m, (ms / 1000), AMPM, M, D, Y);

   return rslt;

}