String time formats
This is used to process the respective time formats in text fields.
◆ TimeStringToSeconds()
static long TimeStringToSeconds |
( |
const std::string & |
timeString | ) |
|
|
inlinestatic |
Converts a time string to the respective integer value.
- Parameters
-
[in] | timeString | String with time.
Following types are possible:
- "MM min" (integer number with "min" on end)
- "HH:MM:SS"
|
- Returns
- Time in seconds
Example:
#include <kodi/tools/StringUtils.h>
◆ SecondsToTimeString()
static std::string SecondsToTimeString |
( |
long |
seconds, |
|
|
TIME_FORMAT |
format = TIME_FORMAT_GUESS |
|
) |
| |
|
inlinestatic |
Convert a time in seconds to a string based on the given time format.
- Parameters
-
[in] | seconds | time in seconds |
[in] | format | [opt] The format we want the time in |
- Returns
- The formatted time
- See also
- TIME_FORMAT
Example:
#include <kodi/tools/StringUtils.h>
std::string ref, var;
ref = "21:30:55";
EXPECT_STREQ(ref.c_str(), var.c_str());
◆ DateStringToYYYYMMDD()
static int DateStringToYYYYMMDD |
( |
const std::string & |
dateString | ) |
|
|
inlinestatic |
Converts a string in the format YYYYMMDD to the corresponding integer value.
- Parameters
-
[in] | dateString | The date in the associated format, possible values are:
- DD (for days only)
- MM-DD (for days with month)
- YYYY-MM-DD (for years, then month and last days)
|
- Returns
- Corresponding integer, e.g. "2020-12-24" return as integer value 20201224
Example:
#include <kodi/tools/StringUtils.h>
int ref, var;
ref = 20120706;
EXPECT_EQ(ref, var);