Skip to content

Commit 27ba3ea

Browse files
committed
Fix format problem with libc++
1 parent d11300c commit 27ba3ea

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/lib/CalendarConverter.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "Client.h"
3131
#include "Exception.h"
3232
#include "types.h"
33+
#include <array>
3334
#include <charconv>
3435
#include <chrono>
3536
#include <cstdlib>
@@ -268,14 +269,14 @@ namespace fbcpp::impl
268269
unsigned minutes;
269270
unsigned seconds;
270271
unsigned fractions;
271-
char timeZoneBuffer[128] = {'\0'};
272+
std::array<char, 128> timeZoneBuffer;
272273

273274
client.getUtil()->decodeTimeTz(statusWrapper, &opaqueTime.value, &hours, &minutes, &seconds, &fractions,
274-
static_cast<unsigned>(sizeof(timeZoneBuffer)), timeZoneBuffer);
275+
static_cast<unsigned>(timeZoneBuffer.size()), timeZoneBuffer.data());
275276

276277
TimeTz timeTz;
277278
timeTz.utcTime = Time{std::chrono::microseconds{ticks}};
278-
timeTz.zone = timeZoneBuffer;
279+
timeTz.zone = timeZoneBuffer.data();
279280

280281
if (decodedTimeZoneName)
281282
*decodedTimeZoneName = timeTz.zone;
@@ -294,12 +295,12 @@ namespace fbcpp::impl
294295
unsigned minutes;
295296
unsigned seconds;
296297
unsigned fractions;
297-
char timeZoneBuffer[128] = {'\0'};
298+
std::array<char, 128> timeZoneBuffer;
298299

299300
client.getUtil()->decodeTimeTz(statusWrapper, &time.value, &hours, &minutes, &seconds, &fractions,
300-
static_cast<unsigned>(sizeof(timeZoneBuffer)), timeZoneBuffer);
301+
static_cast<unsigned>(timeZoneBuffer.size()), timeZoneBuffer.data());
301302

302-
return std::format("{:02}:{:02}:{:02}.{:04} {}", hours, minutes, seconds, fractions, timeZoneBuffer);
303+
return std::format("{:02}:{:02}:{:02}.{:04} {}", hours, minutes, seconds, fractions, timeZoneBuffer.data());
303304
}
304305

305306
TimeTz stringToTimeTz(std::string_view value)
@@ -538,15 +539,15 @@ namespace fbcpp::impl
538539
unsigned minutes;
539540
unsigned seconds;
540541
unsigned subseconds;
541-
char timeZoneBuffer[128] = {'\0'};
542+
std::array<char, 128> timeZoneBuffer;
542543

543544
client.getUtil()->decodeTimeStampTz(statusWrapper, &opaqueTimestamp.value, &year, &month, &day, &hours,
544-
&minutes, &seconds, &subseconds, static_cast<unsigned>(sizeof(timeZoneBuffer)), timeZoneBuffer);
545+
&minutes, &seconds, &subseconds, static_cast<unsigned>(timeZoneBuffer.size()), timeZoneBuffer.data());
545546

546547
TimestampTz timestampTz;
547548
const auto utcLocalTime = BASE_EPOCH + std::chrono::microseconds{ticks};
548549
timestampTz.utcTimestamp = Timestamp::fromLocalTime(utcLocalTime);
549-
timestampTz.zone = timeZoneBuffer;
550+
timestampTz.zone = timeZoneBuffer.data();
550551

551552
if (decodedTimeZoneName)
552553
*decodedTimeZoneName = timestampTz.zone;
@@ -568,13 +569,13 @@ namespace fbcpp::impl
568569
unsigned minutes;
569570
unsigned seconds;
570571
unsigned subseconds;
571-
char timeZoneBuffer[128] = {'\0'};
572+
std::array<char, 128> timeZoneBuffer;
572573

573574
client.getUtil()->decodeTimeStampTz(statusWrapper, &timestamp.value, &year, &month, &day, &hours, &minutes,
574-
&seconds, &subseconds, static_cast<unsigned>(sizeof(timeZoneBuffer)), timeZoneBuffer);
575+
&seconds, &subseconds, static_cast<unsigned>(timeZoneBuffer.size()), timeZoneBuffer.data());
575576

576577
return std::format("{:04}-{:02}-{:02} {:02}:{:02}:{:02}.{:04} {}", year, month, day, hours, minutes,
577-
seconds, subseconds, timeZoneBuffer);
578+
seconds, subseconds, timeZoneBuffer.data());
578579
}
579580

580581
TimestampTz stringToTimestampTz(std::string_view value)

0 commit comments

Comments
 (0)