Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
Time value processing

String time formats
This is used to process the respective time formats in text fields. More...

Functions

static long kodi::tools::StringUtils::TimeStringToSeconds (const std::string &timeString)
 Converts a time string to the respective integer value.
 
static std::string kodi::tools::StringUtils::SecondsToTimeString (long seconds, TIME_FORMAT format=TIME_FORMAT_GUESS)
 Convert a time in seconds to a string based on the given time format.
 
static int kodi::tools::StringUtils::DateStringToYYYYMMDD (const std::string &dateString)
 Converts a string in the format YYYYMMDD to the corresponding integer value.
 

Detailed Description

String time formats
This is used to process the respective time formats in text fields.

Function Documentation

◆ DateStringToYYYYMMDD()

static int kodi::tools::StringUtils::DateStringToYYYYMMDD ( const std::string & dateString)
inlinestatic

Converts a string in the format YYYYMMDD to the corresponding integer value.

Parameters
[in]dateStringThe 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:

int ref, var;
ref = 20120706;
EXPECT_EQ(ref, var);
EXPECT_EQ(dateTime1.GetHour(), 12)
static int DateStringToYYYYMMDD(const std::string &dateString)
Converts a string in the format YYYYMMDD to the corresponding integer value.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:3007

◆ SecondsToTimeString()

static std::string kodi::tools::StringUtils::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]secondstime in seconds
[in]format[opt] The format we want the time in
Returns
The formatted time
See also
TIME_FORMAT

Example:

std::string ref, var;
ref = "21:30:55";
EXPECT_STREQ(ref.c_str(), var.c_str());
static std::string SecondsToTimeString(long seconds, TIME_FORMAT format=TIME_FORMAT_GUESS)
Convert a time in seconds to a string based on the given time format.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:2941

◆ TimeStringToSeconds()

static long kodi::tools::StringUtils::TimeStringToSeconds ( const std::string & timeString)
inlinestatic

Converts a time string to the respective integer value.

Parameters
[in]timeStringString with time.
Following types are possible:
  • "MM min" (integer number with "min" on end)
  • "HH:MM:SS"
Returns
Time in seconds

Example:

EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds(" \t\t 02:04:03 \n "));
EXPECT_EQ(1*3600+5*60+2, kodi::tools::StringUtils::TimeStringToSeconds("01:05:02:04:03 \n "));
static long TimeStringToSeconds(const std::string &timeString)
Converts a time string to the respective integer value.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:2895