From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/time/wcsftime.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/time/wcsftime.c (limited to 'src/time/wcsftime.c') diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c new file mode 100644 index 0000000..8e1437b --- /dev/null +++ b/src/time/wcsftime.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include "locale_impl.h" +#include "time_impl.h" + +size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, const struct tm *restrict tm, locale_t loc) +{ + size_t l, k; + char buf[100]; + wchar_t wbuf[100]; + wchar_t *p; + const char *t_mb; + const wchar_t *t; + int pad, plus; + unsigned long width; + for (l=0; ltm_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; + wmemcpy(s+l, t, k); + l += k; + } + if (n) { + if (l==n) l=n-1; + s[l] = 0; + } + return 0; +} + +size_t wcsftime(wchar_t *restrict wcs, size_t n, const wchar_t *restrict f, const struct tm *restrict tm) +{ + return __wcsftime_l(wcs, n, f, tm, CURRENT_LOCALE); +} + +weak_alias(__wcsftime_l, wcsftime_l); -- cgit v1.2.3