Public Member Functions | Protected Attributes | List of all members
Time Class Reference

Utility for handling time. Internally, uses tm (C time structure). More...

#include <Time.h>

Inheritance diagram for Time:
Inheritance graph
[legend]
Collaboration diagram for Time:
Collaboration graph
[legend]

Public Member Functions

 Time (time_t unixSeconds)
 
 Time (const std::string &time, const std::string &format, bool STRICT=true)
 
void setTime ()
 Sets time to current UTC time.
 
void setTime (time_t time)
 Sets time to UTC time. More...
 
void setTime (const std::string &time, const std::string &format, bool STRICT=true)
 Sets time. More...
 
void setTime (const tm &time)
 
const tm & getTm () const
 Sets time to UTC time. More...
 
time_t getTime () const
 Returns time in seconds.
 
const std::string & str (const std::string &format="") const
 Returns the std::string using formatting as defined by strftime()
 
void reset ()
 
void debug ()
 

Protected Attributes

std::string timeStr
 

Detailed Description

Utility for handling time. Internally, uses tm (C time structure).

Note: This class does nout (yet) support format strings of arbitrary size. (output str length has limited size).

Member Function Documentation

◆ getTm()

const tm& getTm ( ) const
inline

Sets time to UTC time.

Returns the C struct.

◆ setTime() [1/2]

void setTime ( const std::string &  time,
const std::string &  format,
bool  STRICT = true 
)

Sets time.

time - time given as a std::string .
format - format of time parameter, for example "%Y/%m/%d %H:%M".
strictness - if \true, a runtime error is thrown when parsing fails.

Note: handling of Time Zone is odd:

  • Giving unix seconds (input format="%s") changes time zone to local time (EET in Finland)
  • Giving time zone explicitly (input format="%Z"), eg. "2018/11/16 22:58 EET" has no effect; the time is understood as GMT time

The time can be adjusted using several subsequent calls.

◆ setTime() [2/2]

void setTime ( time_t  time)
inline

Sets time to UTC time.

time - unix seconds (integer)

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