Skip to content

Commit 9d35bf5

Browse files
Abseil Teamcopybara-github
authored andcommitted
Import of CCTZ from GitHub.
PiperOrigin-RevId: 837071460 Change-Id: I3eb138b10ef122c1fb6c7e02701ed6c7d1deb34f
1 parent b9baf19 commit 9d35bf5

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

absl/time/internal/cctz/src/time_zone_format.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <limits>
4141
#include <string>
4242
#include <vector>
43-
#if !HAS_STRPTIME
43+
#if !defined(HAS_STRPTIME)
4444
#include <iomanip>
4545
#include <sstream>
4646
#endif
@@ -56,7 +56,7 @@ namespace detail {
5656

5757
namespace {
5858

59-
#if !HAS_STRPTIME
59+
#if !defined(HAS_STRPTIME)
6060
// Build a strptime() using C++11's std::get_time().
6161
char* strptime(const char* s, const char* fmt, std::tm* tm) {
6262
std::istringstream input(s);

absl/time/internal/cctz/src/time_zone_name_win.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <algorithm>
2525
#include <atomic>
26+
#include <cstddef>
2627
#include <cstdint>
2728
#include <limits>
2829
#include <string>
@@ -135,15 +136,14 @@ std::string Utf16ToUtf8(const wchar_t* ptr, size_t size) {
135136
}
136137
const int chars_len = static_cast<int>(size);
137138
std::string result;
138-
std::int32_t len = std::max<std::int32_t>(
139-
static_cast<std::int32_t>(std::min<size_t>(
140-
result.capacity(), std::numeric_limits<std::int32_t>::max())),
141-
1);
139+
std::size_t len = std::max<std::size_t>(
140+
std::min<size_t>(result.capacity(), std::numeric_limits<int>::max()), 1);
142141
do {
143142
result.resize(len);
144143
// TODO: Switch to std::string::data() when we require C++17 or higher.
145-
len = ::WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, ptr, chars_len,
146-
&result[0], len, nullptr, nullptr);
144+
len = static_cast<std::size_t>(::WideCharToMultiByte(
145+
CP_UTF8, WC_ERR_INVALID_CHARS, ptr, chars_len, &result[0],
146+
static_cast<int>(len), nullptr, nullptr));
147147
} while (len > result.size());
148148
result.resize(len);
149149
return result;
@@ -163,15 +163,14 @@ std::string GetWindowsLocalTimeZone() {
163163
}
164164

165165
std::wstring result;
166-
std::int32_t len = std::max<std::int32_t>(
167-
static_cast<std::int32_t>(std::min<size_t>(
168-
result.capacity(), std::numeric_limits<std::int32_t>::max())),
169-
1);
166+
std::size_t len = std::max<std::size_t>(
167+
std::min<size_t>(result.capacity(), std::numeric_limits<int>::max()), 1);
170168
for (;;) {
171169
UErrorCode status = U_ZERO_ERROR;
172170
result.resize(len);
173-
len = getTimeZoneIDForWindowsID(info.TimeZoneKeyName, -1, nullptr,
174-
&result[0], len, &status);
171+
len = static_cast<std::size_t>(
172+
getTimeZoneIDForWindowsID(info.TimeZoneKeyName, -1, nullptr, &result[0],
173+
static_cast<int>(len), &status));
175174
if (U_SUCCESS(status)) {
176175
return Utf16ToUtf8(result.data(), len);
177176
}

0 commit comments

Comments
 (0)