GClasses
GClasses::GTime Class Reference

Detailed Description

Provides some time-related functions.

#include <GTime.h>

Static Public Member Functions

static void appendTimeStampValue (std::string *pS, const char *sep1="-", const char *sep2=" ", const char *sep3=":", bool bGreenwichMeanTime=false)
 Adds a string representation of the current time to pS in big Endian format. For example, if sep1="-", sep2=" ", and sep3=":", and the time is one second before 2010, then it would append a string like this to pS: "2009-12-31 23:59:59". If the separators are all "", then it would append "20091231235959". More...
 
static const char * asciiTime (char *szBuf, int nSize, bool bGreenwichMeanTime=false)
 Returns a string representation of the current time. More...
 
static bool fromString (double *pOutTime, const char *szData, const char *szFormat)
 Parses szData into a double representing the number of seconds since midnight, Jan 1, 1970. The format of szData is specified in szFormat, where Y=year, M=month, D=day, h=hour, m=minute, s=second, and all other characters are expected to match exactly. For example, if szFormat is "YYYY-MM-DD hh:mm:ss" then szData might be "2014-04-01 23:59:59". If the string fits, then *pOutTime will be set to the parsed time, and true is returned. Otherwise, *pOutTime is unchanged, and false is returned. As a special case, the "s" format also includes decimal values. For example, the string "01/20/2015 16:07:23.000" could be parsed with the format "MM/DD/YYYY hh:mm:ssssss". More...
 
static double seconds ()
 Returns the number of seconds since "time X" with at least millisecond precision. On Linux, "time X" is the Epoch (midnight, Jan 1, 1970, GMT). On Windows, "time X" is the time when the system was started. More...
 

Member Function Documentation

static void GClasses::GTime::appendTimeStampValue ( std::string *  pS,
const char *  sep1 = "-",
const char *  sep2 = " ",
const char *  sep3 = ":",
bool  bGreenwichMeanTime = false 
)
static

Adds a string representation of the current time to pS in big Endian format. For example, if sep1="-", sep2=" ", and sep3=":", and the time is one second before 2010, then it would append a string like this to pS: "2009-12-31 23:59:59". If the separators are all "", then it would append "20091231235959".

static const char* GClasses::GTime::asciiTime ( char *  szBuf,
int  nSize,
bool  bGreenwichMeanTime = false 
)
static

Returns a string representation of the current time.

static bool GClasses::GTime::fromString ( double *  pOutTime,
const char *  szData,
const char *  szFormat 
)
static

Parses szData into a double representing the number of seconds since midnight, Jan 1, 1970. The format of szData is specified in szFormat, where Y=year, M=month, D=day, h=hour, m=minute, s=second, and all other characters are expected to match exactly. For example, if szFormat is "YYYY-MM-DD hh:mm:ss" then szData might be "2014-04-01 23:59:59". If the string fits, then *pOutTime will be set to the parsed time, and true is returned. Otherwise, *pOutTime is unchanged, and false is returned. As a special case, the "s" format also includes decimal values. For example, the string "01/20/2015 16:07:23.000" could be parsed with the format "MM/DD/YYYY hh:mm:ssssss".

static double GClasses::GTime::seconds ( )
static

Returns the number of seconds since "time X" with at least millisecond precision. On Linux, "time X" is the Epoch (midnight, Jan 1, 1970, GMT). On Windows, "time X" is the time when the system was started.