1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// --------------------------------------------------------------------------
//
// File
// Name: BoxTime.h
// Purpose: How time is represented
// Created: 2003/10/08
//
// --------------------------------------------------------------------------
#ifndef BOXTIME__H
#define BOXTIME__H
// Time is presented as a signed 64 bit integer, in microseconds
typedef int64_t box_time_t;
#define NANO_SEC_IN_SEC (1000000000LL)
#define NANO_SEC_IN_USEC (1000)
#define NANO_SEC_IN_USEC_LL (1000LL)
#define MICRO_SEC_IN_SEC (1000000)
#define MICRO_SEC_IN_SEC_LL (1000000LL)
#define MICRO_SEC_IN_MILLI_SEC (1000)
#define MILLI_SEC_IN_SEC (1000)
#define MILLI_SEC_IN_SEC_LL (1000LL)
box_time_t GetCurrentBoxTime();
inline box_time_t SecondsToBoxTime(time_t Seconds)
{
return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
}
inline uint64_t MilliSecondsToBoxTime(int64_t milliseconds)
{
return ((box_time_t)milliseconds * 1000);
}
inline time_t BoxTimeToSeconds(box_time_t Time)
{
return Time / MICRO_SEC_IN_SEC_LL;
}
inline uint64_t BoxTimeToMilliSeconds(box_time_t Time)
{
return Time / MILLI_SEC_IN_SEC_LL;
}
inline uint64_t BoxTimeToMicroSeconds(box_time_t Time)
{
return Time;
}
std::string FormatTime(box_time_t time, bool includeDate,
bool showMicros = false);
void ShortSleep(box_time_t duration, bool logDuration);
#endif // BOXTIME__H
|