Skip to content

Commit 7515df9

Browse files
committed
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 <[email protected]>
1 parent 3ae962f commit 7515df9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/shell/modules/date_service.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ static int get_h_m_s(const struct shell *sh, struct tm *t, char *time_str)
123123
return -EINVAL;
124124
}
125125

126-
/* Note range allows for a leap second */
127-
if ((t->tm_sec < 0) || (t->tm_sec > 60)) {
126+
/* Note that leap seconds are not accepted because
127+
* SYS_CLOCK_REALTIME uses Unix time which doesn't support them.
128+
*/
129+
if ((t->tm_sec < 0) || (t->tm_sec > 59)) {
128130
shell_error(sh, "Invalid second");
129131
return -EINVAL;
130132
}

0 commit comments

Comments
 (0)