mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 11:47:28 +00:00
fix strftime %y for negative years
commit 583ea83541
fixed the case where
tm_year is negative but the resulting year (offset by 1900) was still
positive, which is always the case for time_t values that fit in 32
bits, but not for arbitrary inputs.
based on an earlier patch by Julien Ramseier which was overlooked at
the time the previous fix was applied.
This commit is contained in:
parent
8fe1f2d79b
commit
61fb81e395
@ -166,8 +166,8 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
|
||||
item = T_FMT;
|
||||
goto nl_strftime;
|
||||
case 'y':
|
||||
val = tm->tm_year % 100;
|
||||
if (val<0) val += 100;
|
||||
val = (tm->tm_year + 1900LL) % 100;
|
||||
if (val < 0) val = -val;
|
||||
goto number;
|
||||
case 'Y':
|
||||
val = tm->tm_year + 1900LL;
|
||||
|
Loading…
Reference in New Issue
Block a user