path: root/src/time
diff options
authorRich Felker <>2018-02-05 13:36:04 -0500
committerRich Felker <>2018-02-05 13:38:21 -0500
commit596207aa38b0db33f222c9924a1310fee3de88b5 (patch)
tree07ae5a402c134e8e3a8d3f734760009209fe71d0 /src/time
parentcc7c300d1af22641b012268a959ac42f15341ed8 (diff)
fix strftime field widths with %F format and zero year
the code to strip initial sign and leading zeros inadvertently stripped all the zeros and the subsequent '-' separating the month. instead, only strip sign characters from the very first position, and only strip zeros when they are followed by another digit. based on testing by Dennis W├Âlfing.
Diffstat (limited to 'src/time')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/time/strftime.c b/src/time/strftime.c
index d1ca7cae..16b3bb21 100644
--- a/src/time/strftime.c
+++ b/src/time/strftime.c
@@ -251,7 +251,8 @@ size_t __strftime_l(char *restrict s, size_t n, const char *restrict f, const st
t = __strftime_fmt_1(&buf, &k, *f, tm, loc, pad);
if (!t) break;
if (width) {
- for (; *t=='+' || *t=='-' || (*t=='0'&&t[1]); t++, k--);
+ if (*t=='+' || *t=='-') t++, k--;
+ for (; *t=='0' && t[1]-'0'<10U; t++, k--);
if (plus && tm->tm_year >= 10000-1900)
s[l++] = '+';