mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 06:10:04 +00:00
Use HH date library when not using MSVC
This commit is contained in:
parent
e78dc9b3db
commit
593010acc2
10 changed files with 98 additions and 14 deletions
|
|
@ -30,6 +30,10 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace qt
|
namespace qt
|
||||||
|
|
@ -407,8 +411,14 @@ void MainWindow::on_resourceTreeView_doubleClicked(const QModelIndex& index)
|
||||||
|
|
||||||
static const std::string timeFormat {"%Y-%m-%d %H:%M:%S"};
|
static const std::string timeFormat {"%Y-%m-%d %H:%M:%S"};
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::istringstream in {selectedString};
|
std::istringstream in {selectedString};
|
||||||
in >> std::chrono::parse(timeFormat, time);
|
in >> parse(timeFormat, time);
|
||||||
|
|
||||||
if (in.fail())
|
if (in.fail())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <mbgl/util/constants.hpp>
|
#include <mbgl/util/constants.hpp>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -95,8 +99,16 @@ void OverlayLayer::Render(
|
||||||
|
|
||||||
if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr)
|
if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr)
|
||||||
{
|
{
|
||||||
|
const scwx::util::time_zone* currentZone;
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
currentZone = std::chrono::current_zone();
|
||||||
|
#else
|
||||||
|
currentZone = date::current_zone();
|
||||||
|
#endif
|
||||||
|
|
||||||
p->sweepTimeString_ = scwx::util::TimeString(
|
p->sweepTimeString_ = scwx::util::TimeString(
|
||||||
radarProductView->sweep_time(), std::chrono::current_zone(), false);
|
radarProductView->sweep_time(), currentZone, false);
|
||||||
p->sweepTimeNeedsUpdate_ = false;
|
p->sweepTimeNeedsUpdate_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,26 @@
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/tz.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
typedef std::chrono::time_zone time_zone;
|
||||||
|
#else
|
||||||
|
typedef date::time_zone time_zone;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate,
|
std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate,
|
||||||
uint32_t milliseconds);
|
uint32_t milliseconds);
|
||||||
|
|
||||||
std::string TimeString(std::chrono::system_clock::time_point time,
|
std::string TimeString(std::chrono::system_clock::time_point time,
|
||||||
const std::chrono::time_zone* timeZone = nullptr,
|
const time_zone* timeZone = nullptr,
|
||||||
bool epochValid = true);
|
bool epochValid = true);
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace awips
|
namespace awips
|
||||||
|
|
@ -98,6 +102,10 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines,
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
static const std::string timeFormat {"%H%MZ"};
|
static const std::string timeFormat {"%H%MZ"};
|
||||||
|
|
||||||
std::istringstream in {time};
|
std::istringstream in {time};
|
||||||
|
|
@ -106,12 +114,12 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines,
|
||||||
|
|
||||||
if (time.size() == 5 && !in.fail())
|
if (time.size() == 5 && !in.fail())
|
||||||
{
|
{
|
||||||
p->time_ = hh_mm_ss {tp};
|
p->time_ = std::chrono::hh_mm_ss {tp};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger_->warn("Invalid time: \"{}\"", time);
|
logger_->warn("Invalid time: \"{}\"", time);
|
||||||
p->time_ = hh_mm_ss<minutes> {};
|
p->time_ = std::chrono::hh_mm_ss<minutes> {};
|
||||||
dataValid = false;
|
dataValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
#include <boost/bimap.hpp>
|
#include <boost/bimap.hpp>
|
||||||
#include <boost/bimap/unordered_set_of.hpp>
|
#include <boost/bimap/unordered_set_of.hpp>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace awips
|
namespace awips
|
||||||
|
|
@ -87,7 +91,7 @@ public:
|
||||||
PVtec::PVtec() : p(std::make_unique<PVtecImpl>()) {}
|
PVtec::PVtec() : p(std::make_unique<PVtecImpl>()) {}
|
||||||
PVtec::~PVtec() = default;
|
PVtec::~PVtec() = default;
|
||||||
|
|
||||||
PVtec::PVtec(PVtec&&) noexcept = default;
|
PVtec::PVtec(PVtec&&) noexcept = default;
|
||||||
PVtec& PVtec::operator=(PVtec&&) noexcept = default;
|
PVtec& PVtec::operator=(PVtec&&) noexcept = default;
|
||||||
|
|
||||||
PVtec::ProductType PVtec::fixed_identifier() const
|
PVtec::ProductType PVtec::fixed_identifier() const
|
||||||
|
|
@ -134,6 +138,10 @@ bool PVtec::Parse(const std::string& s)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
// P-VTEC takes the form:
|
// P-VTEC takes the form:
|
||||||
// /k.aaa.cccc.pp.s.####.yymmddThhnnZ-yymmddThhnnZ/
|
// /k.aaa.cccc.pp.s.####.yymmddThhnnZ-yymmddThhnnZ/
|
||||||
// 012345678901234567890123456789012345678901234567
|
// 012345678901234567890123456789012345678901234567
|
||||||
|
|
@ -187,8 +195,8 @@ bool PVtec::Parse(const std::string& s)
|
||||||
std::istringstream ssEventBegin {sEventBegin};
|
std::istringstream ssEventBegin {sEventBegin};
|
||||||
std::istringstream ssEventEnd {sEventEnd};
|
std::istringstream ssEventEnd {sEventEnd};
|
||||||
|
|
||||||
sys_time<minutes> eventBegin;
|
std::chrono::sys_time<minutes> eventBegin;
|
||||||
sys_time<minutes> eventEnd;
|
std::chrono::sys_time<minutes> eventEnd;
|
||||||
|
|
||||||
ssEventBegin >> parse(dateTimeFormat, eventBegin);
|
ssEventBegin >> parse(dateTimeFormat, eventBegin);
|
||||||
ssEventEnd >> parse(dateTimeFormat, eventEnd);
|
ssEventEnd >> parse(dateTimeFormat, eventEnd);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@
|
||||||
#include <cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -177,13 +181,16 @@ void DirListSAXHandler::Characters(void* userData, const xmlChar* ch, int len)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Date time format: yyyy-mm-dd hh:mm
|
// Date time format: yyyy-mm-dd hh:mm
|
||||||
static const std::string kDateTimeFormat {"%Y-%m-%d %H:%M"};
|
static const std::string kDateTimeFormat {"%Y-%m-%d %H:%M"};
|
||||||
static constexpr size_t kDateTimeSize {16u};
|
|
||||||
|
|
||||||
// Attempt to parse the date time
|
// Attempt to parse the date time
|
||||||
std::istringstream ssCharacters {characters};
|
std::istringstream ssCharacters {characters};
|
||||||
sys_time<minutes> mtime;
|
std::chrono::sys_time<minutes> mtime;
|
||||||
ssCharacters >> parse(kDateTimeFormat, mtime);
|
ssCharacters >> parse(kDateTimeFormat, mtime);
|
||||||
|
|
||||||
if (!ssCharacters.fail())
|
if (!ssCharacters.fail())
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace provider
|
namespace provider
|
||||||
|
|
@ -73,6 +77,10 @@ AwsLevel2DataProvider::GetTimePointFromKey(const std::string& key)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
static const std::string timeFormat {"%Y%m%d_%H%M%S"};
|
static const std::string timeFormat {"%Y%m%d_%H%M%S"};
|
||||||
|
|
||||||
std::string timeStr {key.substr(offset, formatSize)};
|
std::string timeStr {key.substr(offset, formatSize)};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@
|
||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace provider
|
namespace provider
|
||||||
|
|
@ -99,6 +103,10 @@ AwsLevel3DataProvider::GetTimePointFromKey(const std::string& key)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
static const std::string timeFormat {"%Y_%m_%d_%H_%M_%S"};
|
static const std::string timeFormat {"%Y_%m_%d_%H_%M_%S"};
|
||||||
|
|
||||||
std::string timeStr {key.substr(offset, formatSize)};
|
std::string timeStr {key.substr(offset, formatSize)};
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@
|
||||||
#include <cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
# include <date/date.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -69,6 +73,10 @@ WarningsProvider::ListFiles(std::chrono::system_clock::time_point newerThan)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
static const std::regex reWarningsFilename {
|
static const std::regex reWarningsFilename {
|
||||||
"warnings_[0-9]{8}_[0-9]{2}.txt"};
|
"warnings_[0-9]{8}_[0-9]{2}.txt"};
|
||||||
static const std::string dateTimeFormat {"warnings_%Y%m%d_%H.txt"};
|
static const std::string dateTimeFormat {"warnings_%Y%m%d_%H.txt"};
|
||||||
|
|
@ -104,8 +112,8 @@ WarningsProvider::ListFiles(std::chrono::system_clock::time_point newerThan)
|
||||||
for (auto& record : warningRecords)
|
for (auto& record : warningRecords)
|
||||||
{
|
{
|
||||||
// Determine start time
|
// Determine start time
|
||||||
sys_time<hours> startTime;
|
std::chrono::sys_time<hours> startTime;
|
||||||
std::istringstream ssFilename {record.filename_};
|
std::istringstream ssFilename {record.filename_};
|
||||||
|
|
||||||
ssFilename >> parse(dateTimeFormat, startTime);
|
ssFilename >> parse(dateTimeFormat, startTime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,15 @@ std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TimeString(std::chrono::system_clock::time_point time,
|
std::string TimeString(std::chrono::system_clock::time_point time,
|
||||||
const std::chrono::time_zone* timeZone,
|
const time_zone* timeZone,
|
||||||
bool epochValid)
|
bool epochValid)
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
using namespace date;
|
||||||
|
#endif
|
||||||
|
|
||||||
auto timeInSeconds = time_point_cast<seconds>(time);
|
auto timeInSeconds = time_point_cast<seconds>(time);
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue