diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 0898a77f2..0ecd7e049 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -31,6 +31,7 @@ #include #include +#include /** @brief Load supported locale keys * @@ -342,17 +343,38 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) #ifdef DEBUG_TIMEZONES if ( m_adjustLiveTimezone ) { - cDebug() << "Turning off live-timezone adjustments because debugging is on."; + cWarning() << "Turning off live-timezone adjustments because debugging is on."; m_adjustLiveTimezone = false; } #endif #ifdef __FreeBSD__ if ( m_adjustLiveTimezone ) { - cDebug() << "Turning off live-timezone adjustments on FreeBSD."; + cWarning() << "Turning off live-timezone adjustments on FreeBSD."; m_adjustLiveTimezone = false; } #endif + + QString region = CalamaresUtils::getString( configurationMap, "region" ); + QString zone = CalamaresUtils::getString( configurationMap, "zone" ); + if ( !region.isEmpty() && !zone.isEmpty() ) + { + m_startingTimezone = CalamaresUtils::GeoIP::RegionZonePair( region, zone ); + } + else + { + m_startingTimezone + = CalamaresUtils::GeoIP::RegionZonePair( QStringLiteral( "America" ), QStringLiteral( "New_York" ) ); + } + + if ( CalamaresUtils::getBool( configurationMap, "useSystemTimezone", false ) ) + { + auto systemtz = CalamaresUtils::GeoIP::splitTZString( QTimeZone::systemTimeZoneId() ); + if ( systemtz.isValid() ) + { + m_startingTimezone = systemtz; + } + } } Calamares::JobList diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index c8710f4a9..7e634a4a8 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -24,6 +24,7 @@ #include "LocaleConfiguration.h" #include "Job.h" +#include "geoip/Interface.h" #include "locale/TimeZone.h" #include @@ -133,6 +134,10 @@ private: * timezone, and the live system can be made to follow that. */ bool m_adjustLiveTimezone; + + /** @brief The initial timezone (region, zone) specified in the config. + */ + CalamaresUtils::GeoIP::RegionZonePair m_startingTimezone; }; diff --git a/src/modules/locale/locale.conf b/src/modules/locale/locale.conf index 572326f0b..8236a879b 100644 --- a/src/modules/locale/locale.conf +++ b/src/modules/locale/locale.conf @@ -11,9 +11,21 @@ # the locale page can be set through keys *region* and *zone*. # If either is not set, defaults to America/New_York. # +# Note that useSystemTimezone and GeoIP settings can change the +# starting time zone. +# region: "America" zone: "New_York" +# Instead of using *region* and *zone* specified above, +# you can use the system's notion of the timezone, instead. +# This can help if your system is automatically configured with +# a sensible TZ rather than chasing a fixed default. +# +# The default is false. +# +# useSystemTimezone: true + # Should changing the system location (e.g. clicking around on the timezone # map) immediately reflect the changed timezone in the live system? # By default, installers (with a target system) do, and setup (e.g. OEM diff --git a/src/modules/locale/locale.schema.yaml b/src/modules/locale/locale.schema.yaml index 6eadb5c85..d6c35020f 100644 --- a/src/modules/locale/locale.schema.yaml +++ b/src/modules/locale/locale.schema.yaml @@ -19,6 +19,7 @@ properties: ] } zone: { type: string } + useSystemTimezone: { type: boolean, default: false } adjustLiveTimezone: { type: boolean, default: true }