Scopira  20080306
scopira::tool::timestamp Class Reference

#include <time.h>

Public Member Functions

 timestamp (void)
 constructors
 
 timestamp (time_t t)
 
bool is_null (void) const
 checks for null time
 
 timestamp (int year, int month, int day, int hour, int minute, int second, int dst=-1)
 
void format (const std::string &format, std::string &out, bool gmt=false) const
 
int get_day (void) const
 gets the day of the time value (1-31)
 
int get_day_of_week (void) const
 gets the day of the week of the time value (0-6, 0=Sunday)
 
int get_hour (void) const
 gets the hour of the local time value (0-23, 0=Sunday)
 
int get_minute (void) const
 gets the minute of the time value (0-59)
 
int get_month (void) const
 gets the month of the time value (0-11, 0=January)
 
int get_second (void) const
 gets the second of the time value (0-59)
 
int get_year (void) const
 gets the year of the time value (current year minus 1900)
 
time_t get_time (void) const
 gets the current time value (seconds since January 1, 1970)
 
tm * get_tm (void) const
 
bool operator< (timestamp rhs) const
 comparison operators
 
bool operator<= (timestamp rhs) const
 
bool operator> (timestamp rhs) const
 
bool operator>= (timestamp rhs) const
 
bool operator== (timestamp rhs) const
 
bool operator!= (timestamp rhs) const
 
timestamp operator+ (timespan rhs) const
 
timestamp operator+= (timespan rhs)
 
timestamp operator- (timespan rhs) const
 
timestamp operator-= (timespan rhs)
 
timestampoperator= (timestamp rhs)
 assignment operators
 
timestampoperator= (time_t rhs)
 
timespan operator- (timestamp rhs) const
 subtraction operator to retreive the timespan difference of two times
 

Static Public Member Functions

static timestamp current_time (void)
 gets the current time for the local time zone
 
static int string_to_month (const std::string &month)
 converts a 3 letter string to a numberic month
 

Detailed Description

time class

Author
Aleksander Demko

Constructor & Destructor Documentation

◆ timestamp()

scopira::tool::timestamp::timestamp ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  dst = -1 
)

constructor initializes a time with the following parameters parameters should be based on local time

Parameters
year1900..
month0..11
day1..31
hour0..23
minute0..59
second0..59
dst<0 for default, 0 if dst not in effect, >0 if dst in effect
Author
Aleksander Demko

Member Function Documentation

◆ format()

void scopira::tool::timestamp::format ( const std::string &  format,
std::string &  out,
bool  gmt = false 
) const

formats the time using a format string

Parameters
formata format string (see docs for strftime for format details) the formatted time create a gmt formatted time
Author
Aleksander Demko

◆ get_tm()

tm* scopira::tool::timestamp::get_tm ( void  ) const
inline

gets the a tm struct of the local time Get the time data with this method and then get individual data items if more than one time unit is needed.

Returns
the tm struct
Author
Aleksander Demko

◆ operator+()

timestamp scopira::tool::timestamp::operator+ ( timespan  rhs) const
inline

addition and subtraction operators add and subtract timespan objects from time


The documentation for this class was generated from the following file: