Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions  Download package

SAPDB_Char* RTESys_BuildSQLTimeStamp ( SAPDB_UInt8  microSecondsSinceEpoch,
RTESys_SQLTimestamp VAR_ARRAY_REF  timeBuffer 
)

Fill the given kernel timestamp buffer with local time information.

-------------------------------------------------------------------- Format SAPDB_SQLTIMESTAMP_FORMAT YYYYMMDDHHMMSSmmmuuu

Parameters:
microSecondsSinceEpoch [in] micro seconds since epoch
timeBuffer [out] the time buffer to fill with local time
Returns:
Pointer to first character

Definition at line 316 of file RTESys_Time.c.

References RTESys_TimeZoneDelta().

Referenced by SysView_SysViewBase::AddColumn().

{
    SAPDB_Char *ptr;
#if defined(WIN32)
    SYSTEMTIME dateTime;
    union {
        FILETIME asFILETIME;
        SAPDB_UInt8 asUInt8;
    } utcTime;

    utcTime.asUInt8 = ( ( microSecondsSinceEpoch * (SAPDB_UInt8)10 )
                      + ( RTESys_TimeZoneDelta() * RTESYS_SEC_TO_100NANO )
                      + (*(SAPDB_UInt8 *)&RTESys_epoch) );
    FileTimeToSystemTime(&utcTime.asFILETIME, &dateTime);

    ptr = &timeBuffer[sizeof(RTESys_SQLTimestamp)];
    /* no microseconds in SYSTEMTIME */
    ptr = FillDigits( (SAPDB_UInt8)0,                      ptr, 3, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wMilliseconds, ptr, 3, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wSecond,       ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wMinute,       ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wHour,         ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wDay,          ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wMonth,        ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)dateTime.wYear,         ptr, 4, (SAPDB_Char)0);
#else
    time_t utcTime = (time_t)(microSecondsSinceEpoch/1000000);
    struct tm localTimeBuffer;
    struct tm *tim = &localTimeBuffer;

    EmergencyLocalOrGmtTime( utcTime, tim, WANT_LOCAL_TIMESTAMP );

    ptr = (SAPDB_Char *)&timeBuffer[sizeof(RTESys_SQLTimestamp)];
      ptr = FillDigits( microSecondsSinceEpoch%((SAPDB_UInt8)1000000), ptr, 6, (SAPDB_Char)0);
      ptr = FillDigits( (SAPDB_UInt8)tim->tm_sec,                      ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)tim->tm_min,                      ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)tim->tm_hour,                     ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)tim->tm_mday,                     ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)(tim->tm_mon+1),                  ptr, 2, (SAPDB_Char)0);
    ptr = FillDigits( (SAPDB_UInt8)(tim->tm_year+1900),              ptr, 4, (SAPDB_Char)0);
#endif
    return  (SAPDB_Char *)&timeBuffer[0];
}


Generated by  Doxygen 1.6.0   Back to index