Skip to content

Commit c9c1560

Browse files
committed
shell: date_service: make clear that leap seconds are not supported
SYS_CLOCK_REALTIME is following Unix time so, even if tm_sec == 60 is accepted, make very clear that leap seconds are not supported. Signed-off-by: Diego Herranz <[email protected]>
1 parent 3ae962f commit c9c1560

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/shell/modules/date_service.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ 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 */
126+
/* Note range allows for a leap second, even if not supported */
127127
if ((t->tm_sec < 0) || (t->tm_sec > 60)) {
128128
shell_error(sh, "Invalid second");
129129
return -EINVAL;
130130
}
131131

132+
if (t->tm_sec == 60) {
133+
shell_warn(sh, "Leap seconds not supported in Unix time, "
134+
"so time actually set will be off by 1 second.");
135+
}
136+
132137
return 0;
133138
}
134139

0 commit comments

Comments
 (0)