Display time zone according to settings

This commit is contained in:
Dan Paulat 2024-03-29 22:54:02 -05:00
parent 5fb9dc6a5f
commit d3375de968
4 changed files with 44 additions and 15 deletions

View file

@ -1,12 +1,13 @@
#include <scwx/qt/manager/radar_product_manager.hpp> #include <scwx/qt/manager/radar_product_manager.hpp>
#include <scwx/qt/manager/radar_product_manager_notifier.hpp> #include <scwx/qt/manager/radar_product_manager_notifier.hpp>
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/qt/types/time_types.hpp>
#include <scwx/qt/util/geographic_lib.hpp> #include <scwx/qt/util/geographic_lib.hpp>
#include <scwx/common/constants.hpp> #include <scwx/common/constants.hpp>
#include <scwx/provider/nexrad_data_provider_factory.hpp> #include <scwx/provider/nexrad_data_provider_factory.hpp>
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
#include <scwx/util/map.hpp> #include <scwx/util/map.hpp>
#include <scwx/util/threads.hpp> #include <scwx/util/threads.hpp>
#include <scwx/util/time.hpp>
#include <scwx/wsr88d/nexrad_file_factory.hpp> #include <scwx/wsr88d/nexrad_file_factory.hpp>
#include <deque> #include <deque>
@ -391,6 +392,34 @@ RadarProductManager::coordinates(common::RadialSize radialSize) const
throw std::invalid_argument("Invalid radial size"); throw std::invalid_argument("Invalid radial size");
} }
} }
const scwx::util::time_zone* RadarProductManager::default_time_zone() const
{
types::DefaultTimeZone defaultTimeZone = types::GetDefaultTimeZone(
settings::GeneralSettings::Instance().default_time_zone().GetValue());
switch (defaultTimeZone)
{
case types::DefaultTimeZone::Radar:
{
auto radarSite = radar_site();
if (radarSite != nullptr)
{
return radarSite->time_zone();
}
[[fallthrough]];
}
case types::DefaultTimeZone::Local:
#if defined(_MSC_VER)
return std::chrono::current_zone();
#else
return date::current_zone();
#endif
default:
return nullptr;
}
}
float RadarProductManager::gate_size() const float RadarProductManager::gate_size() const
{ {

View file

@ -5,6 +5,7 @@
#include <scwx/qt/config/radar_site.hpp> #include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/request/nexrad_file_request.hpp> #include <scwx/qt/request/nexrad_file_request.hpp>
#include <scwx/qt/types/radar_product_record.hpp> #include <scwx/qt/types/radar_product_record.hpp>
#include <scwx/util/time.hpp>
#include <scwx/wsr88d/ar2v_file.hpp> #include <scwx/wsr88d/ar2v_file.hpp>
#include <scwx/wsr88d/level3_file.hpp> #include <scwx/wsr88d/level3_file.hpp>
@ -41,8 +42,9 @@ public:
static void DumpRecords(); static void DumpRecords();
const std::vector<float>& coordinates(common::RadialSize radialSize) const; const std::vector<float>& coordinates(common::RadialSize radialSize) const;
float gate_size() const; const scwx::util::time_zone* default_time_zone() const;
std::string radar_id() const; float gate_size() const;
std::string radar_id() const;
std::shared_ptr<config::RadarSite> radar_site() const; std::shared_ptr<config::RadarSite> radar_site() const;
void Initialize(); void Initialize();

View file

@ -288,13 +288,12 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
scwx::util::ClockFormat clockFormat = scwx::util::GetClockFormat( scwx::util::ClockFormat clockFormat = scwx::util::GetClockFormat(
settings::GeneralSettings::Instance().clock_format().GetValue()); settings::GeneralSettings::Instance().clock_format().GetValue());
const scwx::util::time_zone* currentZone; auto radarProductManager = radarProductView->radar_product_manager();
#if defined(_MSC_VER) const scwx::util::time_zone* currentZone =
currentZone = std::chrono::current_zone(); (radarProductManager != nullptr) ?
#else radarProductManager->default_time_zone() :
currentZone = date::current_zone(); nullptr;
#endif
p->sweepTimeString_ = scwx::util::TimeString( p->sweepTimeString_ = scwx::util::TimeString(
radarProductView->sweep_time(), clockFormat, currentZone, false); radarProductView->sweep_time(), clockFormat, currentZone, false);

View file

@ -180,13 +180,12 @@ Level3ProductView::GetDescriptionFields() const
util::ClockFormat clockFormat = util::GetClockFormat( util::ClockFormat clockFormat = util::GetClockFormat(
settings::GeneralSettings::Instance().clock_format().GetValue()); settings::GeneralSettings::Instance().clock_format().GetValue());
const scwx::util::time_zone* currentZone; auto radarProductManager = radar_product_manager();
#if defined(_MSC_VER) const scwx::util::time_zone* currentZone =
currentZone = std::chrono::current_zone(); (radarProductManager != nullptr) ?
#else radarProductManager->default_time_zone() :
currentZone = date::current_zone(); nullptr;
#endif
auto descriptionBlock = p->graphicMessage_->description_block(); auto descriptionBlock = p->graphicMessage_->description_block();