forked from pool/cxxtools
- Add upstream changes to fix build and tests: * 0001-add-missing-header-time.h-to-src-timer.cpp.patch * 0001-remove-timespan-unittest-which-is-prone-to-rounding-.patch * 0001-fix-reading-time-zones-on-32-bit-systems.patch * 0001-remove-range-check-in-serializationinfo.patch OBS-URL: https://build.opensuse.org/request/show/994506 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/cxxtools?expand=0&rev=18
106 lines
3.6 KiB
Diff
106 lines
3.6 KiB
Diff
From c7dd08ea25a5b54922c28f2665c8027d6f93e101 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Tommi=20M=C3=A4kitalo?= <tommi@tntnet.org>
|
|
Date: Tue, 2 Feb 2021 18:27:27 +0100
|
|
Subject: [PATCH] fix reading time zones on 32 bit systems
|
|
|
|
time_t is 32 bit on 32 bit systems but we need 64 bit
|
|
---
|
|
src/tz.cpp | 20 +++++++++++---------
|
|
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/tz.cpp b/src/tz.cpp
|
|
index 599d8f5..66f243b 100644
|
|
--- a/src/tz.cpp
|
|
+++ b/src/tz.cpp
|
|
@@ -52,6 +52,8 @@ log_define("cxxtools.tz")
|
|
namespace cxxtools
|
|
{
|
|
|
|
+typedef int64_t TimeValue;
|
|
+
|
|
class Tz::Impl : public RefCounted
|
|
{
|
|
friend class Tz;
|
|
@@ -81,13 +83,13 @@ class Tz::Impl : public RefCounted
|
|
|
|
struct LeapInfo
|
|
{
|
|
- time_t transitionTime;
|
|
+ TimeValue transitionTime;
|
|
int32_t corrections;
|
|
};
|
|
|
|
struct Transition
|
|
{
|
|
- time_t transitionTime;
|
|
+ TimeValue transitionTime;
|
|
uint8_t ttIndex;
|
|
};
|
|
|
|
@@ -337,7 +339,7 @@ const std::string& Tz::name() const
|
|
|
|
TzDateTime Tz::toLocal(const UtcDateTime& dt) const
|
|
{
|
|
- time_t t = static_cast<time_t>(dt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(dt.msecsSinceEpoch().totalSeconds());
|
|
|
|
uint8_t ttIndex = 0;
|
|
for (unsigned i = 0; i < _impl->transitions.size(); ++i)
|
|
@@ -365,7 +367,7 @@ TzDateTime Tz::toLocal(const UtcDateTime& dt) const
|
|
return TzDateTime(dt + gmtoff, tzName, gmtoff, isdst, leapSeconds);
|
|
}
|
|
|
|
-static std::string timeT2s(time_t t)
|
|
+static std::string timeT2s(TimeValue t)
|
|
{
|
|
return cxxtools::DateTime::fromMSecsSinceEpoch(cxxtools::Seconds(t)).toString();
|
|
}
|
|
@@ -377,7 +379,7 @@ UtcDateTime Tz::toUtc(const LocalDateTime& dt) const
|
|
if (_impl->transitions.empty())
|
|
return UtcDateTime(dt);
|
|
|
|
- time_t t = static_cast<time_t>(dt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(dt.msecsSinceEpoch().totalSeconds());
|
|
unsigned i;
|
|
for (i = 0; i < _impl->transitions.size() - 1; ++i)
|
|
{
|
|
@@ -417,7 +419,7 @@ UtcDateTime Tz::toUtc(const LocalDateTime& dt, bool early) const
|
|
if (_impl->transitions.empty())
|
|
return UtcDateTime(dt);
|
|
|
|
- time_t t = static_cast<time_t>(dt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(dt.msecsSinceEpoch().totalSeconds());
|
|
unsigned i;
|
|
for (i = 0; i < _impl->transitions.size() - 1; ++i)
|
|
{
|
|
@@ -464,7 +466,7 @@ UtcDateTime Tz::previousChange(const cxxtools::DateTime& dt, bool local) const
|
|
|
|
if (!_impl->transitions.empty())
|
|
{
|
|
- time_t t = static_cast<time_t>(dt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(dt.msecsSinceEpoch().totalSeconds());
|
|
for (unsigned i = 0; i < _impl->transitions.size() - 1; ++i)
|
|
{
|
|
if (_impl->transitions[i + 1].transitionTime > t)
|
|
@@ -484,7 +486,7 @@ UtcDateTime Tz::nextChange(const cxxtools::DateTime& dt, bool local) const
|
|
|
|
if (!_impl->transitions.empty())
|
|
{
|
|
- time_t t = static_cast<time_t>(dt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(dt.msecsSinceEpoch().totalSeconds());
|
|
for (unsigned i = 0; i < _impl->transitions.size() - 1; ++i)
|
|
{
|
|
if (_impl->transitions[i + 1].transitionTime > t)
|
|
@@ -500,7 +502,7 @@ UtcDateTime Tz::nextChange(const cxxtools::DateTime& dt, bool local) const
|
|
|
|
cxxtools::Timespan Tz::offset(const UtcDateTime& gmtDt) const
|
|
{
|
|
- time_t t = static_cast<time_t>(gmtDt.msecsSinceEpoch().totalSeconds());
|
|
+ TimeValue t = static_cast<TimeValue>(gmtDt.msecsSinceEpoch().totalSeconds());
|
|
|
|
uint8_t ttIndex = 0;
|
|
for (unsigned i = 0; i < _impl->transitions.size(); ++i)
|
|
--
|
|
2.37.1
|
|
|