Skip to content

Commit d5798ee

Browse files
committed
[math] Fix DateTime parsing for single digit month-days
1 parent f402893 commit d5798ee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/modm/math/calendar/date_time.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,13 @@ class DateTime
219219
static consteval DateTime
220220
fromBuildTime()
221221
{
222-
// Example: "Mon Dec 23 17:45:35 2024"
222+
// Example: "Mon Dec 23 17:45:35 2024" or "Wed Jan 1 14:16:06 2025"
223223
const std::string_view timestamp{__TIMESTAMP__};
224+
224225
const auto to_uint = [=](uint8_t offset, uint8_t length) -> uint16_t
225226
{
226-
const auto str = timestamp.substr(offset, length);
227+
auto str = timestamp.substr(offset, length);
228+
if (str[0] == ' ') str = timestamp.substr(offset+1, length-1);
227229
int integer;
228230
(void) std::from_chars(str.begin(), str.end(), integer);
229231
return uint16_t(integer);

0 commit comments

Comments
 (0)