From 51065a3e7d45995af912707c07f9024310e33538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 11 Dec 2024 15:09:31 +0100 Subject: [PATCH] Do not serialize via time_t. Avoids losing resolution (we use milliseconds, time_t is seconds). --- opm/common/utility/MemPacker.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/opm/common/utility/MemPacker.cpp b/opm/common/utility/MemPacker.cpp index f1d6455eac5..1bbae672cc8 100644 --- a/opm/common/utility/MemPacker.cpp +++ b/opm/common/utility/MemPacker.cpp @@ -80,23 +80,22 @@ unpack(std::string& data, const std::vector& buffer, std::size_t& position std::size_t Packing:: packSize(const time_point&) { - return Packing::packSize(std::time_t()); + return Packing::packSize(time_point::duration::rep()); } void Packing:: pack(const time_point& data, std::vector& buffer, std::size_t& position) { - Packing::pack(TimeService::to_time_t(data), - buffer, position); + Packing::pack(data.time_since_epoch().count(), buffer, position); } void Packing:: unpack(time_point& data, const std::vector& buffer, std::size_t& position) { - std::time_t res; - Packing::unpack(res, buffer, position); - data = TimeService::from_time_t(res); + time_point::duration::rep res; + Packing::unpack(res, buffer, position); + data = time_point(time_point::duration(res)); } template struct Packing>;