Skip to content

Commit f7de1c4

Browse files
committed
fixes [core-tcl/482db1d796540e68]: local seconds of day shall be always positive, also for negative base (modulo operation may be negative in C)
1 parent 9dca5c1 commit f7de1c4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

generic/tclClock.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4441,7 +4441,11 @@ ClockAddObjCmd(
44414441
}
44424442

44434443
/* time together as seconds of the day */
4444-
yySecondOfDay = yySeconds = yydate.localSeconds % SECONDS_PER_DAY;
4444+
yySecondOfDay = yydate.localSeconds % SECONDS_PER_DAY;
4445+
if (yySecondOfDay < 0) { /* to positive result of mod */
4446+
yySecondOfDay += SECONDS_PER_DAY;
4447+
}
4448+
yySeconds = yySecondOfDay;
44454449
/* seconds are in localSeconds (relative base date), so reset time here */
44464450
yyHour = 0; yyMinutes = 0; yyMeridian = MER24;
44474451

0 commit comments

Comments
 (0)