Update most instances of current time to use a time offset

This commit is contained in:
Dan Paulat 2025-08-22 23:42:08 -05:00
parent e0a4dee72b
commit bd27d0e562
19 changed files with 48 additions and 38 deletions

View file

@ -2,12 +2,13 @@
#include <scwx/qt/manager/media_manager.hpp>
#include <scwx/qt/manager/position_manager.hpp>
#include <scwx/qt/manager/text_event_manager.hpp>
#include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/settings/audio_settings.hpp>
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/qt/types/location_types.hpp>
#include <scwx/qt/util/geographic_lib.hpp>
#include <scwx/util/logger.hpp>
#include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/util/time.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/thread_pool.hpp>
@ -172,7 +173,7 @@ void AlertManager::Impl::HandleAlert(const types::TextEventKey& key,
// If the event has ended or is inactive, or if the alert is not enabled,
// skip it
if (eventEnd < std::chrono::system_clock::now() || !alertActive ||
if (eventEnd < scwx::util::time::now() || !alertActive ||
!audioSettings.alert_enabled(phenomenon).GetValue())
{
continue;

View file

@ -9,6 +9,7 @@
#include <scwx/util/logger.hpp>
#include <scwx/util/map.hpp>
#include <scwx/util/threads.hpp>
#include <scwx/util/time.hpp>
#include <scwx/wsr88d/nexrad_file_factory.hpp>
#include <execution>
@ -821,7 +822,7 @@ void RadarProductManagerImpl::RefreshDataSync(
auto latestTime = providerManager->provider_->FindLatestTime();
auto updatePeriod = providerManager->provider_->update_period();
auto lastModified = providerManager->provider_->last_modified();
auto sinceLastModified = std::chrono::system_clock::now() - lastModified;
auto sinceLastModified = scwx::util::time::now() - lastModified;
// For the default interval, assume products are updated at a
// constant rate. Expect the next product at a time based on the
@ -939,7 +940,7 @@ RadarProductManager::GetActiveVolumeTimes(
[&](const auto& date)
{
// Don't query for a time point in the future
if (date > std::chrono::system_clock::now())
if (date > scwx::util::time::now())
{
return;
}
@ -1259,7 +1260,7 @@ void RadarProductManagerImpl::PopulateProductTimes(
[&](const auto& date)
{
// Don't query for a time point in the future
if (date > std::chrono::system_clock::now())
if (date > scwx::util::time::now())
{
return;
}
@ -1556,7 +1557,7 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
bool needArchive = true;
static const auto maxChunkDelay = std::chrono::minutes(10);
const std::chrono::system_clock::time_point firstValidChunkTime =
(isEpox ? std::chrono::system_clock::now() : time) - maxChunkDelay;
(isEpox ? scwx::util::time::now() : time) - maxChunkDelay;
// See if we have this one in the chunk provider.
auto chunkFile = std::dynamic_pointer_cast<wsr88d::Ar2vFile>(

View file

@ -678,7 +678,7 @@ void TextEventManager::Impl::Refresh()
// If the time jumps, we should attempt to load from no later than the
// previous load time
auto loadTime =
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
std::chrono::floor<std::chrono::hours>(scwx::util::time::now());
auto startTime = loadTime - loadHistoryDuration_;
if (prevLoadTime_ != std::chrono::sys_time<std::chrono::hours> {})

View file

@ -218,7 +218,7 @@ void TimelineManager::AnimationStepBegin()
p->pinnedTime_ == std::chrono::system_clock::time_point {})
{
// If the selected view type is live, select the current products
p->SelectTimeAsync(std::chrono::system_clock::now() - p->loopTime_);
p->SelectTimeAsync(scwx::util::time::now() - p->loopTime_);
}
else
{
@ -385,8 +385,8 @@ TimelineManager::Impl::GetLoopStartAndEndTimes()
if (viewType_ == types::MapTime::Live ||
pinnedTime_ == std::chrono::system_clock::time_point {})
{
endTime = std::chrono::floor<std::chrono::minutes>(
std::chrono::system_clock::now());
endTime =
std::chrono::floor<std::chrono::minutes>(scwx::util::time::now());
}
else
{
@ -656,8 +656,8 @@ void TimelineManager::Impl::Step(Direction direction)
{
if (direction == Direction::Back)
{
newTime = std::chrono::floor<std::chrono::minutes>(
std::chrono::system_clock::now());
newTime =
std::chrono::floor<std::chrono::minutes>(scwx::util::time::now());
}
else
{
@ -688,7 +688,7 @@ void TimelineManager::Impl::Step(Direction direction)
newTime += 1min;
// If the new time is more than 2 minutes in the future, stop stepping
if (newTime > std::chrono::system_clock::now() + 2min)
if (newTime > scwx::util::time::now() + 2min)
{
break;
}