4 #include "locale_impl.h"
7 const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *tm, locale_t loc, int pad);
9 size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, const struct tm *restrict tm, locale_t loc)
30 if (*f == '-' || *f == '_' || *f == '0') pad = *f++;
31 if ((plus = (*f == '+'))) f++;
32 width = wcstoul(f, &p, 10);
33 if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
34 if (!width && p!=f) width = 1;
39 if (*f == 'E' || *f == 'O') f++;
40 t_mb = __strftime_fmt_1(&buf, &k, *f, tm, loc, pad);
42 k = mbstowcs(wbuf, t_mb, sizeof wbuf / sizeof *wbuf);
43 if (k == (size_t)-1) return 0;
46 for (; *t=='+' || *t=='-' || (*t=='0'&&t[1]); t++, k--);
48 if (plus && tm->tm_year >= 10000-1900)
50 else if (tm->tm_year < -1900)
54 for (; width > k && l < n; width--)
57 if (k >= n-l) k = n-l;
68 size_t wcsftime(wchar_t *restrict wcs, size_t n, const wchar_t *restrict f, const struct tm *restrict tm)
70 return __wcsftime_l(wcs, n, f, tm, CURRENT_LOCALE);
73 weak_alias(__wcsftime_l, wcsftime_l);