|
<< Click to Display Table of Contents >> C Examples: DbiTimeStampDecode |
![]() ![]()
|
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;
}