Class for time operations, calculations, and timing.
More...
#include <sttnet_English.h>
|
| 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 Duration & | calculateTime (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...
|
| |
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
| 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
-
| time1 | The time to be subtracted from |
| time2 | The time to subtract |
| result | A Duration container to receive the result |
| format1 | Time string format of time1 (default is ISO08086A standard) |
| format2 | Time 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
-
| time1 | The time string to operate on |
| time2 | The duration to operate with |
| result | A string container to receive the result time string |
| am | '+' for addition, '-' for subtraction |
| format1 | Format of time1 (default is ISO08086A standard) |
| format2 | Format 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
-
| time1 | The first time string to compare |
| time2 | The second time string to compare |
| format1 | Format of time1 (default is ISO08086A standard) |
| format2 | Format 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
-
| timeStr | The original time string |
| oldFormat | Original time string format |
| newFormat | New 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
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
-
| timeStr | The string container to receive the time |
| format | Specify 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: