8 #ifndef BOOSTER_POSIX_TIME_H 9 #define BOOSTER_POSIX_TIME_H 11 #include <booster/config.h> 32 ptime(
long long seconds=0,
int nano=0) :
96 return ptime(v/one_e3,v%one_e3 * one_e6);
111 return ptime(v/one_e6,v%one_e6 * one_e3);
126 return ptime(v/one_e9,v%one_e9);
154 return ptime(v*3600);
168 return ptime(v*(3600*24));
176 return double(t.sec) + double(t.nsec) * 1e-9;
183 double sec = floor(d);
184 double subsec = d-sec;
185 long long seconds =
static_cast<long long>(sec);
186 int nano =
static_cast<int>(floor(subsec * 1e9));
187 if(nano < 0) nano = 0;
188 if(nano >= one_e9) nano = one_e9-1;
189 return ptime(seconds,nano);
197 return ptime(sec+other.sec,nsec+other.nsec);
206 *
this =
ptime(sec+other.sec,nsec+other.nsec);
215 return ptime(sec-other.sec,nsec-other.nsec);
224 *
this =
ptime(sec-other.sec,nsec-other.nsec);
228 bool operator==(
ptime const &other)
const 230 return sec==other.sec && nsec == other.nsec;
232 bool operator!=(
ptime const &other)
const 234 return !((*this)==other);
236 bool operator<(
ptime const &other)
const 242 return nsec < other.nsec;
244 bool operator>(
ptime const &other)
const 246 return other < *
this;
248 bool operator <= (
ptime const &other)
const 250 return !(*
this > other);
252 bool operator >=(
ptime const &other)
const 254 return !(*
this < other);
289 sleep(milliseconds(v));
296 sleep(nanoseconds(v));
301 static void sleep(
ptime const &v );
307 sec += nsec / one_e9;
308 nsec = nsec % one_e9;
317 static const int one_e3 = 1000;
318 static const int one_e6 = 1000000;
319 static const int one_e9 = 1000000000;
328 BOOSTER_API std::ostream &operator<<(std::ostream &,
ptime const &);
static ptime milliseconds(long long v)
Definition: posix_time.h:94
BOOSTER_API std::tm universal_time(time_t pt)
int get_milliseconds() const
Definition: posix_time.h:56
static long long nanoseconds(ptime const &p)
Definition: posix_time.h:117
static ptime from_number(double d)
Definition: posix_time.h:181
static ptime days(long long v)
Definition: posix_time.h:166
static double to_number(ptime const &t)
Definition: posix_time.h:174
std::basic_string< CharType > normalize(std::basic_string< CharType > const &str, norm_type n=norm_default, std::locale const &loc=std::locale())
Definition: conversion.h:159
long long get_seconds() const
Definition: posix_time.h:42
static long long milliseconds(ptime const &p)
Definition: posix_time.h:87
static void millisleep(long long v)
Definition: posix_time.h:287
static long long minutes(ptime const &p)
Definition: posix_time.h:138
static ptime microseconds(long long v)
Definition: posix_time.h:109
int get_nanoseconds() const
Definition: posix_time.h:49
ptime(long long seconds=0, int nano=0)
Definition: posix_time.h:32
static ptime nanoseconds(long long v)
Definition: posix_time.h:124
ptime operator+(ptime const &other) const
Definition: posix_time.h:195
static long long days(ptime const &p)
Definition: posix_time.h:159
static long long hours(ptime const &p)
Definition: posix_time.h:145
static void nanosleep(long long v)
Definition: posix_time.h:294
static long long seconds(ptime const &p)
Definition: posix_time.h:71
BOOSTER_API std::istream & operator>>(std::istream &, ptime &)
ptime & operator+=(ptime const &other)
Definition: posix_time.h:204
static ptime const zero
Definition: posix_time.h:282
int get_microseconds() const
Definition: posix_time.h:63
This class represents POSIX time.
Definition: posix_time.h:26
static long long microseconds(ptime const &p)
Definition: posix_time.h:102
static ptime minutes(long long v)
Definition: posix_time.h:131
ptime & operator-=(ptime const &other)
Definition: posix_time.h:222
ptime operator-(ptime const &other) const
Definition: posix_time.h:213
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
BOOSTER_API std::tm local_time(time_t pt)
static ptime seconds(long long v)
Definition: posix_time.h:78
static ptime hours(long long v)
Definition: posix_time.h:152