Compare commits

..

No commits in common. '857e9bb6a9ea54d1a90b4e47ac0756f323e0f118' and '6167d127ba6e7cf293b08bde957e3ee8c6ced39e' have entirely different histories.

  1. 14
      cpp/src/CMakeLists.txt
  2. 16
      cpp/src/monoformat_parseonly.cpp

@ -1,10 +1,12 @@
set(monoformat_SOURCES set(monoformat_SOURCES
monoformat_schema.cpp monoformat_schema.cpp
monoformat_structured.cpp
monoformat_parseonly.cpp monoformat_parseonly.cpp
monoformat_fontreader.cpp monoformat_fontreader.cpp
) )
set(monoformat_HEADERS set(monoformat_HEADERS
monoformat_schema.hpp monoformat_schema.hpp
monoformat_structured.hpp
monoformat_parsehelpers.hpp monoformat_parsehelpers.hpp
monoformat_parseonly.hpp monoformat_parseonly.hpp
monoformat_fontreader.hpp monoformat_fontreader.hpp
@ -12,18 +14,6 @@ set(monoformat_HEADERS
monoformat_utf8.hpp monoformat_utf8.hpp
) )
option(MONOFORMAT_EMBEDDED "Only build for embedded devices" FALSE)
if(NOT MONOFORMAT_EMBEDDED)
list(APPEND monoformat_SOURCES
monoformat_structured.cpp
)
list(APPEND monoformat_HEADERS
monoformat_structured.hpp
)
endif()
add_library(monoformat ${monoformat_SOURCES} ${monoformat_HEADERS}) add_library(monoformat ${monoformat_SOURCES} ${monoformat_HEADERS})
target_compile_features(monoformat PUBLIC cxx_std_23) target_compile_features(monoformat PUBLIC cxx_std_23)
target_include_directories(monoformat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(monoformat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

@ -4,7 +4,7 @@
#include <string_view> #include <string_view>
#include <string> #include <string>
#include <cstdio> #include <format>
#include <iostream> #include <iostream>
namespace monoformat { namespace monoformat {
@ -1029,19 +1029,17 @@ std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& bu
} }
} }
char text[32] = {}; std::string text;
if (showHours && showMinutes && showSeconds) { if (showHours && showMinutes && showSeconds) {
std::snprintf(text, sizeof(text), "%02d:%02d:%02d", int(hours), int(minutes), int(seconds)); text = std::format("{:02d}:{:02d}:{:02d}", hours, minutes, seconds);
} else if (showHours && showMinutes) { } else if (showHours && showMinutes) {
std::snprintf(text, sizeof(text), "%02d:%02d", int(hours), int(minutes)); text = std::format("{:02d}:{:02d}", hours, minutes);
} else if (showHours) { } else if (showHours) {
std::snprintf(text, sizeof(text), "%02d", int(hours)); text = std::format("{:02d}", hours);
} else if (showMinutes && showSeconds) { } else if (showMinutes && showSeconds) {
std::snprintf(text, sizeof(text), "%02d:%02d", int(minutes), int(seconds)); text = std::format("{:02d}:{:02d}", minutes, seconds);
} else if (showSeconds) { } else if (showSeconds) {
std::snprintf(text, sizeof(text), "%02d", int(seconds)); text = std::format("{:02d}", seconds);
} else if (showMinutes) {
std::snprintf(text, sizeof(text), "%02d", int(minutes));
} else { } else {
return {}; return {};
} }

Loading…
Cancel
Save