- t = __strftime_fmt_1(&buf, *f, tm, loc);
- if (!t || (k = strlen(t)) >= n-l)
- return 0;
+ t = __strftime_fmt_1(&buf, &k, *f, tm, loc);
+ if (!t) break;
+ if (width) {
+ for (; *t=='+' || *t=='-' || (*t=='0'&&t[1]); t++, k--);
+ width--;
+ if (plus && tm->tm_year >= 10000-1900)
+ s[l++] = '+';
+ else if (tm->tm_year < -1900)
+ s[l++] = '-';
+ else
+ width++;
+ for (; width > k && l < n; width--)
+ s[l++] = '0';
+ }
+ if (k > n-l) k = n-l;