/*****************************************************************************/ /* Software Testing Automation Framework (STAF) */ /* (C) Copyright IBM Corp. 2001 */ /* */ /* This software is licensed under the Eclipse Public License (EPL) V1.0. */ /*****************************************************************************/ #ifndef STAF_Timestamp #define STAF_Timestamp #include #include "STAFError.h" #ifdef __cplusplus extern "C" { #endif typedef struct STAFRelativeTimeImpl *STAFRelativeTime_t; /****************************************************************************/ /* STAFThreadSafeLocalTimeString - This is a thread safe wrapper around */ /* strftime() */ /* */ /* Accepts: (In) Pointer to buffer in which to place time string */ /* (In) Size of buffer */ /* (In) Format string (identical to that accepted by strftime()) */ /* (In) The time to convert to a string (obtained from time()) */ /* (Out) Pointer to OS return code */ /* */ /* Returns: kSTAFOk, on success */ /* other on error */ /****************************************************************************/ STAFRC_t STAFThreadSafeLocalTimeString(char *buffer, unsigned int bufSize, const char *format, time_t theTime, unsigned int *osRC); /****************************************************************************/ /* STAFThreadSafeLocalTime - Provides a thread safe wrapper around */ /* localtime() */ /* */ /* Accepts: (Out) Pointer to a tm structure (from */ /* (In) The time to convert to a string (obtained from time()) */ /* (Out) Pointer to OS return code */ /* */ /* Returns: kSTAFOk, on success */ /* other on error */ /****************************************************************************/ STAFRC_t STAFThreadSafeLocalTime(struct tm *theTM, time_t theTime, unsigned int *osRC); /****************************************************************************/ /* STAFTimestampGetRelativeTime - Gets the current relative time */ /* */ /* Accepts: (Out) Pointer to a relative time */ /* (Out) Pointer to OS return code */ /* */ /* Returns: kSTAFOk, on success */ /* other on error */ /****************************************************************************/ STAFRC_t STAFTimestampGetRelativeTime(STAFRelativeTime_t *relTime, unsigned int *osRC); /****************************************************************************/ /* STAFTimestampGetRelativeTimeDifference - Gets the difference (in */ /* milliseconds) between two */ /* relative times */ /* */ /* Accepts: (In) Relative time 1 */ /* (In) Relative time 2 */ /* (Out) (Relative time 1 - Relative time 2) in milliseconds */ /* */ /* Returns: kSTAFOk, on success */ /* other on error */ /* */ /* Notes : 1) The difference is undefined if Relative Time 1 is less than */ /* Relative Time 2 */ /* 2) The difference is undefined if it would be greater than the */ /* size of an unsigned int */ /****************************************************************************/ STAFRC_t STAFTimestampGetRelativeTimeDifference(const STAFRelativeTime_t lhs, const STAFRelativeTime_t rhs, unsigned int *diffInMillis); /****************************************************************************/ /* STAFTimestampFreeRelativeTime - Frees a relative time */ /* */ /* Accepts: (I/O) Pointer to a relative time */ /* */ /* Returns: kSTAFOk, on success */ /* other on error */ /****************************************************************************/ STAFRC_t STAFTimestampFreeRelativeTime(STAFRelativeTime_t *relTime); #ifdef __cplusplus } #include "STAFString.h" #include "STAFException.h" // STAFTimestamp - Represents a specific point in time. Provides methods // to convert the timestamp to a string and to seconds // past midnight, as well as operator-(). class STAFTimestamp { public: // Accepted input formats are // //