123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- #ifndef __D_TIMESTAMP__
- #define __D_TIMESTAMP__
- #include <iostream>
- using namespace std;
- namespace DUtils {
- class Timestamp
- {
- public:
-
- enum tOptions
- {
- NONE = 0,
- CURRENT_TIME = 0x1,
- ZERO = 0x2
- };
-
- public:
-
-
- Timestamp(Timestamp::tOptions option = NONE);
-
-
- virtual ~Timestamp(void);
-
- bool empty() const;
-
- void setToCurrentTime();
-
- inline void setTime(unsigned long secs, unsigned long usecs){
- m_secs = secs;
- m_usecs = usecs;
- }
-
-
- inline void getTime(unsigned long &secs, unsigned long &usecs) const
- {
- secs = m_secs;
- usecs = m_usecs;
- }
-
- void setTime(const string &stime);
-
-
- void setTime(double s);
-
-
- double getFloatTime() const;
-
- string getStringTime() const;
-
- double operator- (const Timestamp &t) const;
-
- Timestamp plus(unsigned long s, unsigned long us) const;
-
- Timestamp minus(unsigned long s, unsigned long us) const;
-
- Timestamp& operator+= (double s);
-
-
- Timestamp& operator-= (double s);
-
- Timestamp operator+ (double s) const;
-
- Timestamp operator- (double s) const;
-
- bool operator> (const Timestamp &t) const;
-
- bool operator>= (const Timestamp &t) const;
-
- bool operator== (const Timestamp &t) const;
-
- bool operator< (const Timestamp &t) const;
-
- bool operator<= (const Timestamp &t) const;
-
- string Format(bool machine_friendly = false) const;
-
- static string Format(double s);
-
- protected:
-
- unsigned long m_secs;
-
- unsigned long m_usecs;
- };
- }
- #endif
|