DUtils::Timestamp Class Reference

Timestamp. More...

#include <Timestamp.h>

List of all members.

Public Types

enum  tOptions { NONE = 0, CURRENT_TIME = 0x1, ZERO = 0x2 }
 

Options to initiate a timestamp.


Public Member Functions

 Timestamp (Timestamp::tOptions option=NONE)
virtual ~Timestamp (void)
bool empty () const
void setToCurrentTime ()
void setTime (unsigned long secs, unsigned long usecs)
void getTime (unsigned long &secs, unsigned long &usecs) const
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
Timestampoperator+= (double s)
Timestampoperator-= (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 Public Member Functions

static string Format (double s)

Protected Attributes

unsigned long m_secs
 Seconds.
unsigned long m_usecs
 Microseconds.

Detailed Description

Timestamp.


Constructor & Destructor Documentation

Timestamp::Timestamp ( Timestamp::tOptions  option = NONE  ) 

Creates a timestamp

Parameters:
option option to set the initial time stamp
Timestamp::~Timestamp ( void   )  [virtual]

Destructor


Member Function Documentation

bool Timestamp::empty (  )  const

Says if the timestamp is "empty": seconds and usecs are both 0, as when initiated with the ZERO flag

Returns:
true iif secs == usecs == 0
string Timestamp::Format ( double  s  )  [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

Parameters:
s,: elapsed seconds (given by getFloatTime) to format
string Timestamp::Format ( bool  machine_friendly = false  )  const

Returns the timestamp in a human-readable string

Parameters:
machine_friendly if true, the returned string is formatted to yyyymmdd_hhmmss, without weekday or spaces
Note:
This has not been tested under Windows
The timestamp is truncated to seconds
double Timestamp::getFloatTime (  )  const

Returns this timestamp as the number of seconds in (long) float format

string Timestamp::getStringTime (  )  const

Returns this timestamp as the number of seconds in fixed length string format

void DUtils::Timestamp::getTime ( unsigned long &  secs,
unsigned long &  usecs 
) const [inline]

Returns the timestamp in seconds and microseconds

Parameters:
secs seconds
usecs microseconds
Timestamp Timestamp::minus ( unsigned long  s,
unsigned long  us 
) const

Returns a copy of this timestamp - s seconds - us microseconds

Parameters:
s seconds
us microseconds
Timestamp Timestamp::operator+ ( double  s  )  const

Returns a copy of this timestamp + s seconds

Parameters:
s,: seconds
Timestamp & Timestamp::operator+= ( double  s  ) 

Adds s seconds to this timestamp and returns a reference to itself

Parameters:
s seconds
Returns:
reference to this timestamp
Timestamp Timestamp::operator- ( double  s  )  const

Returns a copy of this timestamp - s seconds

Parameters:
s,: seconds
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

Parameters:
t,: timestamp to subtract from this timestamp
Returns:
difference in seconds
Timestamp & Timestamp::operator-= ( double  s  ) 

Substracts s seconds to this timestamp and returns a reference to itself

Parameters:
s seconds
Returns:
reference to this timestamp
bool Timestamp::operator< ( const Timestamp t  )  const

Returns whether this timestamp is at the past of t

Parameters:
t 
bool Timestamp::operator<= ( const Timestamp t  )  const

Returns whether this timestamp is at the past of (or is the same as) t

Parameters:
t 
bool Timestamp::operator== ( const Timestamp t  )  const

Returns whether this timestamp and t represent the same instant

Parameters:
t 
bool Timestamp::operator> ( const Timestamp t  )  const

Returns whether this timestamp is at the future of t

Parameters:
t 
bool Timestamp::operator>= ( const Timestamp t  )  const

Returns whether this timestamp is at the future of (or is the same as) t

Parameters:
t 
Timestamp Timestamp::plus ( unsigned long  s,
unsigned long  us 
) const

Returns a copy of this timestamp + s seconds + us microseconds

Parameters:
s seconds
us microseconds
void Timestamp::setTime ( double  s  ) 

Sets the timestamp from a number of seconds from the epoch

Parameters:
s seconds from the epoch
void Timestamp::setTime ( const string &  stime  ) 

Sets the timestamp from a string with the time in seconds

Parameters:
stime,: string such as "1235603336.036609"
void DUtils::Timestamp::setTime ( unsigned long  secs,
unsigned long  usecs 
) [inline]

Sets the timestamp from seconds and microseconds

Parameters:
secs,: seconds
usecs,: microseconds
void Timestamp::setToCurrentTime (  ) 

Sets this instance to the current time


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Friends
Generated on Thu Feb 7 19:16:00 2013 by  doxygen 1.6.3