aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <3226626+ksooo@users.noreply.github.com>2023-04-16 17:38:49 +0200
committerGitHub <noreply@github.com>2023-04-16 17:38:49 +0200
commit23dc2d55cdf5d26cfbd31ad55abe875a1f6b196b (patch)
tree7068da8e626eac8264f50cdc3de5d5ff896cebe2
parentda09f3f2d0dfe14566c8982ee48876e307e93e23 (diff)
parent5128bc5fe1beb5624e89be47c5a6373599de9b64 (diff)
Merge pull request #23151 from DeltaMikeCharlie/SettingsDateFormatPreview
[GUI][Settings] Add formatting string to date format selection preview in region settings.
-rw-r--r--xbmc/LangInfo.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp
index 27596cbdb8..d5ebf014ae 100644
--- a/xbmc/LangInfo.cpp
+++ b/xbmc/LangInfo.cpp
@@ -35,6 +35,16 @@
#include <algorithm>
#include <stdexcept>
+namespace
+{
+std::string GetDateStringWithFormat(const CDateTime& date, const std::string& format)
+{
+ // Return the formatted date together with the format used.
+ // eg: '1/02/2003 (D/MM/YYYY)'
+ return date.GetAsLocalizedDate(format) + " (" + format + ")";
+}
+} // namespace
+
using namespace PVR;
static std::string shortDateFormats[] = {
@@ -1288,10 +1298,11 @@ void CLangInfo::SettingOptionsShortDateFormatsFiller(const SettingConstPtr& sett
CDateTime now = CDateTime::GetCurrentDateTime();
- list.emplace_back(
- StringUtils::Format(g_localizeStrings.Get(20035),
- now.GetAsLocalizedDate(g_langInfo.m_currentRegion->m_strDateFormatShort)),
- SETTING_REGIONAL_DEFAULT);
+ list.emplace_back(StringUtils::Format(g_localizeStrings.Get(20035),
+ GetDateStringWithFormat(
+ now, g_langInfo.m_currentRegion->m_strDateFormatShort)),
+ SETTING_REGIONAL_DEFAULT);
+
if (shortDateFormatSetting == SETTING_REGIONAL_DEFAULT)
{
match = true;
@@ -1300,7 +1311,7 @@ void CLangInfo::SettingOptionsShortDateFormatsFiller(const SettingConstPtr& sett
for (const std::string& shortDateFormat : shortDateFormats)
{
- list.emplace_back(now.GetAsLocalizedDate(shortDateFormat), shortDateFormat);
+ list.emplace_back(GetDateStringWithFormat(now, shortDateFormat), shortDateFormat);
if (!match && shortDateFormatSetting == shortDateFormat)
{
@@ -1323,10 +1334,11 @@ void CLangInfo::SettingOptionsLongDateFormatsFiller(const SettingConstPtr& setti
CDateTime now = CDateTime::GetCurrentDateTime();
- list.emplace_back(
- StringUtils::Format(g_localizeStrings.Get(20035),
- now.GetAsLocalizedDate(g_langInfo.m_currentRegion->m_strDateFormatLong)),
- SETTING_REGIONAL_DEFAULT);
+ list.emplace_back(StringUtils::Format(g_localizeStrings.Get(20035),
+ GetDateStringWithFormat(
+ now, g_langInfo.m_currentRegion->m_strDateFormatLong)),
+ SETTING_REGIONAL_DEFAULT);
+
if (longDateFormatSetting == SETTING_REGIONAL_DEFAULT)
{
match = true;
@@ -1335,7 +1347,7 @@ void CLangInfo::SettingOptionsLongDateFormatsFiller(const SettingConstPtr& setti
for (const std::string& longDateFormat : longDateFormats)
{
- list.emplace_back(now.GetAsLocalizedDate(longDateFormat), longDateFormat);
+ list.emplace_back(GetDateStringWithFormat(now, longDateFormat), longDateFormat);
if (!match && longDateFormatSetting == longDateFormat)
{