STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
stt::time::DateTime Class Reference

Class for time operations, calculations, and timing. More...

#include <sttnet_English.h>

Inheritance diagram for stt::time::DateTime:
stt::file::LogFile

Public Member Functions

bool startTiming ()
 Start timing. More...
 
Duration checkTime ()
 Check time during timing. More...
 
Duration endTiming ()
 Stop timing. More...
 
Duration getDt ()
 Get the last timing duration. More...
 
bool isStart ()
 Return the timing status of the object. More...
 

Static Public Member Functions

static std::string & getTime (std::string &timeStr, const std::string &format=ISO8086A)
 Get the current time. More...
 
static bool convertFormat (std::string &timeStr, const std::string &oldFormat, const std::string &newFormat=ISO8086A)
 Convert the format of a time string. More...
 
static DurationcalculateTime (const std::string &time1, const std::string &time2, Duration &result, const std::string &format1=ISO8086A, const std::string &format2=ISO8086A)
 Calculate the difference between two time strings. More...
 
static std::string & calculateTime (const std::string &time1, const Duration &time2, std::string &result, const std::string &am, const std::string &format1=ISO8086A, const std::string &format2=ISO8086A)
 Add or subtract a duration from a time string. More...
 
static bool compareTime (const std::string &time1, const std::string &time2, const std::string &format1=ISO8086A, const std::string &format2=ISO8086A)
 Compare the magnitudes of two time strings. More...
 

Detailed Description

Class for time operations, calculations, and timing.

Accurate to milliseconds

Warning
Only accurate within 1970 ± 292 years
Bug:
Only accurate within 1970 ± 292 years, to be optimized

Member Function Documentation

static Duration& stt::time::DateTime::calculateTime ( const std::string &  time1,
const std::string &  time2,
Duration result,
const std::string &  format1 = ISO8086A,
const std::string &  format2 = ISO8086A 
)
static

Calculate the difference between two time strings.

Parameters
time1The time to be subtracted from
time2The time to subtract
resultA Duration container to receive the result
format1Time string format of time1 (default is ISO08086A standard)
format2Time string format of time2 (default is ISO08086A standard)
Returns
Reference to result
static std::string& stt::time::DateTime::calculateTime ( const std::string &  time1,
const Duration time2,
std::string &  result,
const std::string &  am,
const std::string &  format1 = ISO8086A,
const std::string &  format2 = ISO8086A 
)
static

Add or subtract a duration from a time string.

Parameters
time1The time string to operate on
time2The duration to operate with
resultA string container to receive the result time string
am'+' for addition, '-' for subtraction
format1Format of time1 (default is ISO08086A standard)
format2Format of result (default is ISO08086A standard)
Returns
Reference to result
Duration stt::time::DateTime::checkTime ( )

Check time during timing.

Returns
A Duration recording the elapsed time so far
static bool stt::time::DateTime::compareTime ( const std::string &  time1,
const std::string &  time2,
const std::string &  format1 = ISO8086A,
const std::string &  format2 = ISO8086A 
)
static

Compare the magnitudes of two time strings.

Note
Later times are considered larger.
Parameters
time1The first time string to compare
time2The second time string to compare
format1Format of time1 (default is ISO08086A standard)
format2Format of time2 (default is ISO08086A standard)
Returns
true if time1 >= time2, false otherwise
static bool stt::time::DateTime::convertFormat ( std::string &  timeStr,
const std::string &  oldFormat,
const std::string &  newFormat = ISO8086A 
)
static

Convert the format of a time string.

Note
Modify the original string via reference
Parameters
timeStrThe original time string
oldFormatOriginal time string format
newFormatNew time format (default is ISO08086A standard)
Returns
true for success, false for failure
Duration stt::time::DateTime::endTiming ( )

Stop timing.

Returns
A Duration recording the elapsed time
Note
The object saves the last timing result
Duration stt::time::DateTime::getDt ( )
inline

Get the last timing duration.

Returns
A Duration recording the elapsed time
static std::string& stt::time::DateTime::getTime ( std::string &  timeStr,
const std::string &  format = ISO8086A 
)
static

Get the current time.

Note
Get the current time and return it as a string
Parameters
timeStrThe string container to receive the time
formatSpecify the time string format (default is 'yyyy-mm-ddThh:mi:ss', i.e., ISO08086A standard)
Returns
Reference to timeStr
bool stt::time::DateTime::isStart ( )
inline

Return the timing status of the object.

Returns
true if timing is in progress, false otherwise
bool stt::time::DateTime::startTiming ( )

Start timing.

Returns
true for successful start, false for failure

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