#include <Timestamp.h>
Public Types | |
| enum | tOptions { NONE = 0, CURRENT_TIME = 0x1, ZERO = 0x2 } |
| Options to initiate a timestamp. More... | |
Public Member Functions | |
| bool | empty () const |
| string | Format (bool machine_friendly=false) const |
| double | getFloatTime () const |
| string | getStringTime () const |
| void | getTime (unsigned long &secs, unsigned long &usecs) const |
| Timestamp | minus (unsigned long s, unsigned long us) const |
| Timestamp | operator+ (double s) const |
| Timestamp & | operator+= (double s) |
| double | operator- (const Timestamp &t) const |
| Timestamp | operator- (double s) const |
| Timestamp & | operator-= (double s) |
| 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 |
| Timestamp | plus (unsigned long s, unsigned long us) const |
| void | setTime (unsigned long secs, unsigned long usecs) |
| void | setTime (const string &stime) |
| void | setTime (double s) |
| void | setToCurrentTime () |
| Timestamp (Timestamp::tOptions option=NONE) | |
| virtual | ~Timestamp (void) |
Static Public Member Functions | |
| static string | Format (double s) |
Protected Attributes | |
| unsigned long | m_secs |
| Seconds. More... | |
| unsigned long | m_usecs |
| Microseconds. More... | |
Definition at line 19 of file Timestamp.h.
Options to initiate a timestamp.
| Enumerator | |
|---|---|
| NONE | |
| CURRENT_TIME | |
| ZERO | |
Definition at line 24 of file Timestamp.h.
| Timestamp::Timestamp | ( | Timestamp::tOptions | option = NONE | ) |
Creates a timestamp
| option | option to set the initial time stamp |
Definition at line 39 of file Timestamp.cpp.
|
virtual |
Destructor
Definition at line 47 of file Timestamp.cpp.
| bool Timestamp::empty | ( | ) | const |
Says if the timestamp is "empty": seconds and usecs are both 0, as when initiated with the ZERO flag
Definition at line 51 of file Timestamp.cpp.
| string Timestamp::Format | ( | bool | machine_friendly = false | ) | const |
Returns the timestamp in a human-readable string
| machine_friendly | if true, the returned string is formatted to yyyymmdd_hhmmss, without weekday or spaces |
Definition at line 197 of file Timestamp.cpp.
|
static |
Returns a string version of the elapsed time in seconds, with the format xd hh:mm:ss, hh:mm:ss, mm:ss or s.us
| s | elapsed seconds (given by getFloatTime) to format |
Definition at line 223 of file Timestamp.cpp.
| double Timestamp::getFloatTime | ( | ) | const |
Returns this timestamp as the number of seconds in (long) float format
Definition at line 93 of file Timestamp.cpp.
| string Timestamp::getStringTime | ( | ) | const |
Returns this timestamp as the number of seconds in fixed length string format
Definition at line 97 of file Timestamp.cpp.
|
inline |
Returns the timestamp in seconds and microseconds
| secs | seconds |
| usecs | microseconds |
Definition at line 71 of file Timestamp.h.
| Timestamp Timestamp::minus | ( | unsigned long | s, |
| unsigned long | us | ||
| ) | const |
Returns a copy of this timestamp - s seconds - us microseconds
| s | seconds |
| us | microseconds |
Definition at line 149 of file Timestamp.cpp.
| Timestamp Timestamp::operator+ | ( | double | s | ) | const |
Returns a copy of this timestamp + s seconds
| s | seconds |
Definition at line 119 of file Timestamp.cpp.
| Timestamp & Timestamp::operator+= | ( | double | s | ) |
Adds s seconds to this timestamp and returns a reference to itself
| s | seconds |
Definition at line 107 of file Timestamp.cpp.
| double Timestamp::operator- | ( | const Timestamp & | t | ) | const |
Returns the difference in seconds between this timestamp (greater) and t (smaller) If the order is swapped, a negative number is returned
| t | timestamp to subtract from this timestamp |
Definition at line 103 of file Timestamp.cpp.
| Timestamp Timestamp::operator- | ( | double | s | ) | const |
Returns a copy of this timestamp - s seconds
| s | seconds |
Definition at line 141 of file Timestamp.cpp.
| Timestamp & Timestamp::operator-= | ( | double | s | ) |
Substracts s seconds to this timestamp and returns a reference to itself
| s | seconds |
Definition at line 113 of file Timestamp.cpp.
| bool Timestamp::operator< | ( | const Timestamp & | t | ) | const |
Returns whether this timestamp is at the past of t
| t |
Definition at line 177 of file Timestamp.cpp.
| bool Timestamp::operator<= | ( | const Timestamp & | t | ) | const |
Returns whether this timestamp is at the past of (or is the same as) t
| t |
Definition at line 184 of file Timestamp.cpp.
| bool Timestamp::operator== | ( | const Timestamp & | t | ) | const |
Returns whether this timestamp and t represent the same instant
| t |
Definition at line 191 of file Timestamp.cpp.
| bool Timestamp::operator> | ( | const Timestamp & | t | ) | const |
Returns whether this timestamp is at the future of t
| t |
Definition at line 163 of file Timestamp.cpp.
| bool Timestamp::operator>= | ( | const Timestamp & | t | ) | const |
Returns whether this timestamp is at the future of (or is the same as) t
| t |
Definition at line 170 of file Timestamp.cpp.
| Timestamp Timestamp::plus | ( | unsigned long | s, |
| unsigned long | us | ||
| ) | const |
Returns a copy of this timestamp + s seconds + us microseconds
| s | seconds |
| us | microseconds |
Definition at line 127 of file Timestamp.cpp.
|
inline |
Sets the timestamp from seconds and microseconds
| secs | seconds |
| usecs | microseconds |
Definition at line 61 of file Timestamp.h.
| void Timestamp::setTime | ( | const string & | stime | ) |
Sets the timestamp from a string with the time in seconds
| stime | string such as "1235603336.036609" |
Definition at line 73 of file Timestamp.cpp.
| void Timestamp::setTime | ( | double | s | ) |
Sets the timestamp from a number of seconds from the epoch
| s | seconds from the epoch |
Definition at line 87 of file Timestamp.cpp.
| void Timestamp::setToCurrentTime | ( | ) |
Sets this instance to the current time
Definition at line 56 of file Timestamp.cpp.
|
protected |
Seconds.
Definition at line 196 of file Timestamp.h.
|
protected |
Microseconds.
Definition at line 198 of file Timestamp.h.