diff --git a/traffxml/traff_model.cpp b/traffxml/traff_model.cpp index cd9dbfe37..299b03813 100644 --- a/traffxml/traff_model.cpp +++ b/traffxml/traff_model.cpp @@ -2,6 +2,7 @@ #include "base/logging.hpp" +#include #include using namespace std; @@ -174,7 +175,14 @@ void IsoTime::Shift(IsoTime nowRef) std::string IsoTime::ToString() const { - return std::format("{0:%F}T{0:%T}{0:%Ez}", time_point_cast(m_tp)); + auto const tp_seconds = time_point_cast(m_tp); + auto const time_t = std::chrono::system_clock::to_time_t(tp_seconds); + std::tm tm = *std::gmtime(&time_t); + + std::ostringstream ss; + ss << std::put_time(&tm, "%Y-%m-%dT%H:%M:%S"); + ss << "Z"; + return ss.str(); } bool IsoTime::operator< (IsoTime & rhs) @@ -346,7 +354,9 @@ std::string DebugPrint(IsoTime time) std::ostringstream os; //os << std::put_time(&time.m_tm, "%Y-%m-%d %H:%M:%S %z"); // %FT%T%z - os << std::format("{0:%F} {0:%T} {0:%z}", time.m_tp); + auto const time_t = std::chrono::system_clock::to_time_t(time.m_tp); + std::tm tm = *std::gmtime(&time_t); + os << std::put_time(&tm, "%Y-%m-%d %H:%M:%S UTC"); return os.str(); } @@ -542,7 +552,9 @@ std::string DebugPrint(TraffEvent event) os << "probability: " << (event.m_probability ? std::to_string(event.m_probability.value()) : "nullopt") << ", "; os << "q_duration: " << (event.m_qDurationMins - ? std::format("{:1d}:{:02d}", event.m_qDurationMins.value() / 60, event.m_qDurationMins.value() % 60) + ? (std::to_string(event.m_qDurationMins.value() / 60) + ":" + + (event.m_qDurationMins.value() % 60 < 10 ? "0" : "") + + std::to_string(event.m_qDurationMins.value() % 60)) : "nullopt") << ", "; // TODO other quantifiers diff --git a/traffxml/traff_model_xml.cpp b/traffxml/traff_model_xml.cpp index 96309127d..553b2965e 100644 --- a/traffxml/traff_model_xml.cpp +++ b/traffxml/traff_model_xml.cpp @@ -4,6 +4,7 @@ #include "base/logging.hpp" #include +#include #include #include #include @@ -557,7 +558,10 @@ void PointToXml(Point const & point, std::string name, pugi::xml_node & parentNo if (point.m_junctionRef) node.append_attribute("junction_ref").set_value(point.m_junctionRef.value()); - node.text() = std::format("{0:+.5f} {1:+.5f}", point.m_coordinates.m_lat, point.m_coordinates.m_lon); + std::ostringstream coord_ss; + coord_ss << std::fixed << std::setprecision(5) + << std::showpos << point.m_coordinates.m_lat << " " << point.m_coordinates.m_lon; + node.text() = coord_ss.str().c_str(); } /** @@ -761,7 +765,15 @@ void EventToXml(TraffEvent const & event, pugi::xml_node & node) node.append_attribute("probability").set_value(event.m_probability.value()); if (event.m_qDurationMins) - node.append_attribute("q_duration").set_value(std::format("{:%H:%M}", std::chrono::minutes(event.m_qDurationMins.value()))); + { + auto mins = event.m_qDurationMins.value(); + auto hours = mins / 60; + auto remaining_mins = mins % 60; + std::ostringstream duration_ss; + duration_ss << std::setfill('0') << std::setw(2) << hours << ":" + << std::setw(2) << remaining_mins; + node.append_attribute("q_duration").set_value(duration_ss.str().c_str()); + } // TODO other quantifiers (not yet implemented in struct) @@ -1159,11 +1171,10 @@ std::string FiltersToXml(std::vector & bboxRects) { std::ostringstream os; for (auto rect : bboxRects) - os << std::format("\n", - mercator::YToLat(rect.minY()), - mercator::XToLon(rect.minX()), - mercator::YToLat(rect.maxY()), - mercator::XToLon(rect.maxX())); + os << "\n"; return os.str(); }