28#define sprintf sprintf_s
43 else if (option &
ZERO)
59 struct __timeb32 timebuffer;
60 _ftime32_s(&timebuffer);
63 m_usecs = timebuffer.millitm * 1000;
66 gettimeofday(&now, NULL);
74 string::size_type p = stime.find(
'.');
75 if (p == string::npos) {
76 m_secs = atol(stime.c_str());
80 m_secs = atol(stime.substr(0, p).c_str());
82 string s_usecs = stime.substr(p + 1, 6);
83 m_usecs = atol(stime.substr(p + 1).c_str());
84 m_usecs *= (
unsigned long)pow(10.0,
double(6 - s_usecs.length()));
122 unsigned long secs = (long)floor(s);
123 unsigned long usecs = (long)((s - (
double)secs) * 1e6);
125 return this->
plus(secs, usecs);
132 const unsigned long max = 1000000ul;
144 unsigned long secs = (long)floor(s);
145 unsigned long usecs = (long)((s - (
double)secs) * 1e6);
147 return this->
minus(secs, usecs);
154 const unsigned long max = 1000000ul;
205 localtime_s(&tm_time, &t);
207 localtime_r(&t, &tm_time);
212 if (machine_friendly)
214 strftime(buffer, 128,
"%Y%m%d_%H%M%S", &tm_time);
218 strftime(buffer, 128,
"%c", &tm_time);
221 return string(buffer);
225 int days = int(s / (24. * 3600.0));
226 s -= days * (24. * 3600.0);
227 int hours = int(s / 3600.0);
229 int minutes = int(s / 60.0);
231 int seconds = int(s);
232 int ms = int((s - seconds)*1e6);
237 if ((b = (days > 0))) ss << days <<
"d ";
238 if ((b = (b || hours > 0))) ss << setw(2) << hours <<
":";
239 if ((b = (b || minutes > 0))) ss << setw(2) << minutes <<
":";
240 if (b) ss << setw(2);
242 if (!b) ss <<
"." << setw(6) << ms;
Timestamp operator+(double s) const
double getFloatTime() const
bool operator==(const Timestamp &t) const
void setTime(unsigned long secs, unsigned long usecs)
bool operator<=(const Timestamp &t) const
Timestamp minus(unsigned long s, unsigned long us) const
tOptions
Options to initiate a timestamp.
bool operator<(const Timestamp &t) const
Timestamp & operator+=(double s)
Timestamp & operator-=(double s)
Timestamp(Timestamp::tOptions option=NONE)
unsigned long m_secs
Seconds.
Timestamp plus(unsigned long s, unsigned long us) const
double operator-(const Timestamp &t) const
string Format(bool machine_friendly=false) const
bool operator>(const Timestamp &t) const
bool operator>=(const Timestamp &t) const
string getStringTime() const
unsigned long m_usecs
Microseconds.