diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 908999ab..d2e7ccbb 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -558,7 +558,13 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b, auto usep = static_cast(sep); // Add ASCII '0' to each digit byte and insert separators. digits |= 0x3030003030003030 | (usep << 16) | (usep << 40); - memcpy(buf, &digits, 8); + if (is_big_endian()) { + char tmp[8]; + memcpy(tmp, &digits, 8); + std::reverse_copy(tmp, tmp + 8, buf); + } else { + memcpy(buf, &digits, 8); + } } template FMT_CONSTEXPR inline const char* get_units() {