14 #ifndef __INCLUDED__SCOPIRA_TOOL_TIME_H__ 15 #define __INCLUDED__SCOPIRA_TOOL_TIME_H__ 17 #include <scopira/tool/platform.h> 27 #include <scopira/tool/platform.h> 28 #include <scopira/tool/export.h> 55 SCOPIRA_EXPORT
timespan(
int days,
int hours,
int minutes,
int seconds);
58 bool is_null(
void)
const {
return dm_time == -1; }
61 int get_days(
void)
const {
return static_cast<int>(dm_time / (24*60*60)); }
74 int get_seconds(
void)
const {
return static_cast<int>(dm_time % 60); }
79 bool operator< (timespan rhs)
const {
return dm_time < rhs.dm_time; }
80 bool operator<=(timespan rhs)
const {
return dm_time <= rhs.dm_time; }
81 bool operator> (timespan rhs)
const {
return dm_time > rhs.dm_time; }
82 bool operator>=(timespan rhs)
const {
return dm_time >= rhs.dm_time; }
83 bool operator==(timespan rhs)
const {
return dm_time == rhs.dm_time; }
84 bool operator!=(timespan rhs)
const {
return dm_time != rhs.dm_time; }
87 timespan
operator+ (timespan rhs)
const {
return dm_time + rhs.dm_time; }
88 timespan& operator+=(timespan rhs) { dm_time += rhs.dm_time;
return *
this; }
89 timespan operator- (timespan rhs)
const {
return dm_time - rhs.dm_time; }
90 timespan& operator-=(timespan rhs) { dm_time -= rhs.dm_time;
return *
this; }
93 timespan&
operator= (timespan rhs) { dm_time = rhs.dm_time;
return *
this; }
112 bool is_null(
void)
const {
return dm_time == -1; }
128 SCOPIRA_EXPORT
timestamp(
int year,
int month,
int day,
int hour,
int minute,
int second,
int dst = -1);
138 SCOPIRA_EXPORT
void format(
const std::string& format, std::string& out,
bool gmt=
false)
const;
141 SCOPIRA_EXPORT
static timestamp current_time(
void);
144 int get_day(
void)
const {
return get_tm()->tm_mday; }
148 int get_hour(
void)
const {
return get_tm()->tm_hour; }
156 int get_year(
void)
const {
return get_tm()->tm_year; }
161 #ifdef PLATFORM_win32 163 #pragma warning(push) 164 #pragma warning(disable:4996) 174 tm*
get_tm(
void)
const {
return localtime(&dm_time); }
175 #ifdef PLATFORM_win32 181 bool operator< (timestamp rhs)
const {
return dm_time < rhs.dm_time; }
182 bool operator<=(timestamp rhs)
const {
return dm_time <= rhs.dm_time; }
183 bool operator> (timestamp rhs)
const {
return dm_time > rhs.dm_time; }
184 bool operator>=(timestamp rhs)
const {
return dm_time >= rhs.dm_time; }
185 bool operator==(timestamp rhs)
const {
return dm_time == rhs.dm_time; }
186 bool operator!=(timestamp rhs)
const {
return dm_time != rhs.dm_time; }
191 timestamp operator+=(
timespan rhs) { dm_time += rhs.dm_time;
return *
this; }
192 timestamp operator- (
timespan rhs)
const {
return dm_time - rhs.dm_time; }
193 timestamp operator-=(
timespan rhs) { dm_time -= rhs.dm_time;
return *
this; }
196 timestamp&
operator=(timestamp rhs) { dm_time = rhs.dm_time;
return *
this; }
197 timestamp&
operator=(time_t rhs) { dm_time = rhs;
return *
this; }
203 static int string_to_month(
const std::string& month);
206 void assign(
int year,
int month,
int mday,
int hour,
int minute,
int second,
int isdst = -1,
bool isgmt =
false);
254 SCOPIRA_EXPORT
chrono(
void);
261 SCOPIRA_EXPORT
void reset(
void);
268 SCOPIRA_EXPORT
void start(
void);
279 SCOPIRA_EXPORT
void stop(
void);
290 SCOPIRA_EXPORT
double get_total_time(
void)
const;
299 SCOPIRA_EXPORT
double get_lap_time(
void)
const;
309 SCOPIRA_EXPORT
double get_running_time(
void)
const;
312 struct timeval dm_total, dm_delta;
Definition: archiveflow.h:20