Add additional timezones
This commit is contained in:
@@ -111,6 +111,9 @@ static constexpr TimeZoneEntry TIMEZONES[] = {
|
|||||||
{"CST6CDT,M3.2.0/2,M11.1.0/2"},
|
{"CST6CDT,M3.2.0/2,M11.1.0/2"},
|
||||||
{"MST7MDT,M3.2.0/2,M11.1.0/2"},
|
{"MST7MDT,M3.2.0/2,M11.1.0/2"},
|
||||||
{"PST8PDT,M3.2.0/2,M11.1.0/2"},
|
{"PST8PDT,M3.2.0/2,M11.1.0/2"},
|
||||||
|
{"AST4ADT,M3.2.0/2,M11.1.0/2"},
|
||||||
|
{"ACST-9:30ACDT,M10.1.0/2,M4.1.0/3"},
|
||||||
|
{"AKST9AKDT,M3.2.0/2,M11.1.0/2"},
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---- NVS helpers ----------------------------------------------------------
|
// ---- NVS helpers ----------------------------------------------------------
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ class CrossPointSettings {
|
|||||||
TZ_CST = 13,
|
TZ_CST = 13,
|
||||||
TZ_MST = 14,
|
TZ_MST = 14,
|
||||||
TZ_PST = 15,
|
TZ_PST = 15,
|
||||||
|
TZ_AST_ADT = 16,
|
||||||
|
TZ_ACST_ACDT = 17,
|
||||||
|
TZ_AKST_AKDT = 18,
|
||||||
TIMEZONE_COUNT
|
TIMEZONE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const StrId timeZoneNames[CrossPointSettings::TIMEZONE_COUNT] = {
|
|||||||
StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK,
|
StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK,
|
||||||
StrId::STR_TZ_UTC_PLUS4, StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8,
|
StrId::STR_TZ_UTC_PLUS4, StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8,
|
||||||
StrId::STR_TZ_UTC_PLUS9, StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3,
|
StrId::STR_TZ_UTC_PLUS9, StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3,
|
||||||
StrId::STR_TZ_EST, StrId::STR_TZ_CST, StrId::STR_TZ_MST, StrId::STR_TZ_PST};
|
StrId::STR_TZ_EST, StrId::STR_TZ_CST, StrId::STR_TZ_MST, StrId::STR_TZ_PST,
|
||||||
|
StrId::STR_TZ_UTC, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ClockSettingsActivity::buildMenuItems() {
|
void ClockSettingsActivity::buildMenuItems() {
|
||||||
@@ -25,13 +26,35 @@ void ClockSettingsActivity::buildMenuItems() {
|
|||||||
SettingInfo::Toggle(StrId::STR_USE_CLOCK, &CrossPointSettings::useClock, "useClock", StrId::STR_CAT_SYSTEM));
|
SettingInfo::Toggle(StrId::STR_USE_CLOCK, &CrossPointSettings::useClock, "useClock", StrId::STR_CAT_SYSTEM));
|
||||||
menuItems.push_back(SettingInfo::Enum(StrId::STR_CLOCK_FORMAT, &CrossPointSettings::clockFormat12h,
|
menuItems.push_back(SettingInfo::Enum(StrId::STR_CLOCK_FORMAT, &CrossPointSettings::clockFormat12h,
|
||||||
{StrId::STR_24H, StrId::STR_12H}, "clockFormat12h", StrId::STR_CAT_SYSTEM));
|
{StrId::STR_24H, StrId::STR_12H}, "clockFormat12h", StrId::STR_CAT_SYSTEM));
|
||||||
menuItems.push_back(
|
{
|
||||||
SettingInfo::Enum(StrId::STR_TIMEZONE, &CrossPointSettings::timeZone,
|
auto tzSetting = SettingInfo::Enum(
|
||||||
{StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK,
|
StrId::STR_TIMEZONE, &CrossPointSettings::timeZone,
|
||||||
StrId::STR_TZ_UTC_PLUS4, StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8,
|
{StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK, StrId::STR_TZ_UTC_PLUS4,
|
||||||
StrId::STR_TZ_UTC_PLUS9, StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3,
|
StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8, StrId::STR_TZ_UTC_PLUS9,
|
||||||
StrId::STR_TZ_EST, StrId::STR_TZ_CST, StrId::STR_TZ_MST, StrId::STR_TZ_PST},
|
StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3, StrId::STR_TZ_EST, StrId::STR_TZ_CST,
|
||||||
"timeZone", StrId::STR_CAT_SYSTEM));
|
StrId::STR_TZ_MST, StrId::STR_TZ_PST, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC},
|
||||||
|
"timeZone", StrId::STR_CAT_SYSTEM);
|
||||||
|
tzSetting.enumLabels = {"UTC (GMT/BST)",
|
||||||
|
"Central European (CET/CEST)",
|
||||||
|
"Eastern European (EET/EEST)",
|
||||||
|
"Moscow (MSK)",
|
||||||
|
"UTC+4",
|
||||||
|
"India (IST)",
|
||||||
|
"UTC+7",
|
||||||
|
"UTC+8",
|
||||||
|
"UTC+9",
|
||||||
|
"Australia Eastern (AEST/AEDT)",
|
||||||
|
"New Zealand (NZST/NZDT)",
|
||||||
|
"UTC-3",
|
||||||
|
"Eastern US/Canada (EST/EDT)",
|
||||||
|
"Central US/Canada (CST/CDT)",
|
||||||
|
"Mountain US/Canada (MST/MDT)",
|
||||||
|
"Pacific US/Canada (PST/PDT)",
|
||||||
|
"Atlantic Canada (AST/ADT)",
|
||||||
|
"Australia Central (ACST/ACDT)",
|
||||||
|
"Alaska (AKST/AKDT)"};
|
||||||
|
menuItems.push_back(std::move(tzSetting));
|
||||||
|
}
|
||||||
|
|
||||||
menuItems.push_back(SettingInfo::Action(StrId::STR_DETECT_TIMEZONE, SettingAction::DetectTimezone)
|
menuItems.push_back(SettingInfo::Action(StrId::STR_DETECT_TIMEZONE, SettingAction::DetectTimezone)
|
||||||
.withSubcategory(StrId::STR_READER_TOOLS));
|
.withSubcategory(StrId::STR_READER_TOOLS));
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ bool mapIanaTimezone(const std::string& tz, uint8_t& outSetting) {
|
|||||||
outSetting = TZ::TZ_PST;
|
outSetting = TZ::TZ_PST;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tz == "America/Halifax" || tz == "America/Glace_Bay" || tz == "America/Moncton" || tz == "America/Thule") {
|
||||||
|
outSetting = TZ::TZ_AST_ADT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (tz == "America/Anchorage" || tz == "America/Juneau" || tz == "America/Nome" || tz == "America/Sitka" ||
|
||||||
|
tz == "America/Yakutat" || tz == "America/Metlakatla") {
|
||||||
|
outSetting = TZ::TZ_AKST_AKDT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (tz == "America/Sao_Paulo" || tz == "America/Argentina/Buenos_Aires" || tz == "America/Montevideo") {
|
if (tz == "America/Sao_Paulo" || tz == "America/Argentina/Buenos_Aires" || tz == "America/Montevideo") {
|
||||||
outSetting = TZ::TZ_UTC_MINUS3;
|
outSetting = TZ::TZ_UTC_MINUS3;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ std::string SettingInfo::getDisplayValue() const {
|
|||||||
value = callValueGetter();
|
value = callValueGetter();
|
||||||
else
|
else
|
||||||
return {};
|
return {};
|
||||||
|
if (!enumLabels.empty()) {
|
||||||
|
if (value < enumLabels.size()) return enumLabels[value];
|
||||||
|
return {};
|
||||||
|
}
|
||||||
if (value < enumValues.size()) return std::string(I18N.get(enumValues[value]));
|
if (value < enumValues.size()) return std::string(I18N.get(enumValues[value]));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -61,7 +65,7 @@ void SettingInfo::toggleValue() const {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SettingType::ENUM: {
|
case SettingType::ENUM: {
|
||||||
const auto count = static_cast<uint8_t>(enumValues.size());
|
const auto count = static_cast<uint8_t>(enumLabels.empty() ? enumValues.size() : enumLabels.size());
|
||||||
if (count == 0) break;
|
if (count == 0) break;
|
||||||
if (valuePtr) {
|
if (valuePtr) {
|
||||||
SETTINGS.*(valuePtr) = (SETTINGS.*(valuePtr) + 1) % count;
|
SETTINGS.*(valuePtr) = (SETTINGS.*(valuePtr) + 1) % count;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct SettingInfo {
|
|||||||
SettingType type;
|
SettingType type;
|
||||||
uint8_t CrossPointSettings::* valuePtr = nullptr;
|
uint8_t CrossPointSettings::* valuePtr = nullptr;
|
||||||
std::vector<StrId> enumValues;
|
std::vector<StrId> enumValues;
|
||||||
|
std::vector<std::string> enumLabels;
|
||||||
SettingAction action = SettingAction::None;
|
SettingAction action = SettingAction::None;
|
||||||
|
|
||||||
struct ValueRange {
|
struct ValueRange {
|
||||||
|
|||||||
@@ -1238,8 +1238,14 @@ void CrossPointWebServer::handleGetSettings() const {
|
|||||||
doc["value"] = static_cast<int>(s.callValueGetter());
|
doc["value"] = static_cast<int>(s.callValueGetter());
|
||||||
}
|
}
|
||||||
JsonArray options = doc["options"].to<JsonArray>();
|
JsonArray options = doc["options"].to<JsonArray>();
|
||||||
for (const auto& opt : s.enumValues) {
|
if (!s.enumLabels.empty()) {
|
||||||
options.add(I18N.get(opt));
|
for (const auto& opt : s.enumLabels) {
|
||||||
|
options.add(opt);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const auto& opt : s.enumValues) {
|
||||||
|
options.add(I18N.get(opt));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user