From 7515df9bc2c910bbd90b2896c82823915f303235 Mon Sep 17 00:00:00 2001 From: Diego Herranz Date: Sun, 10 Aug 2025 22:48:23 +0200 Subject: [PATCH] shell: date_service: remove partial support of leap seconds tm_sec == 60 was accepted but it would only result in the time being wrongly set (off by 1 second) since SYS_CLOCK_REALTIME is following Unix time which doesn't support them. Better to not accept them in the first place. Signed-off-by: Diego Herranz --- subsys/shell/modules/date_service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/shell/modules/date_service.c b/subsys/shell/modules/date_service.c index 95ce21185c8b7..765e216f4a3b7 100644 --- a/subsys/shell/modules/date_service.c +++ b/subsys/shell/modules/date_service.c @@ -123,8 +123,10 @@ static int get_h_m_s(const struct shell *sh, struct tm *t, char *time_str) return -EINVAL; } - /* Note range allows for a leap second */ - if ((t->tm_sec < 0) || (t->tm_sec > 60)) { + /* Note that leap seconds are not accepted because + * SYS_CLOCK_REALTIME uses Unix time which doesn't support them. + */ + if ((t->tm_sec < 0) || (t->tm_sec > 59)) { shell_error(sh, "Invalid second"); return -EINVAL; }