From 652839aee0a498a8e15da9e5508fd09df0d4e414 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 4 Sep 2024 16:41:50 +1000 Subject: [PATCH] mgmt: mcumgr: os_mgmt: fix millisecond return Ensure that leading zeros are present in the milliseconds field, otherwise a milliseconds count of 35 will appear as x.35, i.e. 350 milliseconds. With this fix, it will appear as x.035. Signed-off-by: Jordan Yates --- doc/releases/release-notes-4.0.rst | 2 ++ subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index 1c18b8f761e41c..fd732a4c543db5 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -295,6 +295,8 @@ Libraries / Subsystems * Added support for :ref:`mcumgr_smp_group_10`, which allows for listing information on supported groups. + * Fixed formatting of milliseconds in :c:enum:`OS_MGMT_ID_DATETIME_STR` by adding + leading zeros. * Logging diff --git a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c index 21731af7cd4b56..935f3e1552a506 100644 --- a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c @@ -836,7 +836,7 @@ static int os_mgmt_datetime_read(struct smp_streamer *ctxt) sprintf(date_string, "%4d-%02d-%02dT%02d:%02d:%02d" #ifdef CONFIG_MCUMGR_GRP_OS_DATETIME_MS - ".%d" + ".%03d" #endif , (uint16_t)(current_time.tm_year + RTC_DATETIME_YEAR_OFFSET), (uint8_t)(current_time.tm_mon + RTC_DATETIME_MONTH_OFFSET),