- blk = resize((char *)blk, size);
- len = strftime((char *)blk, size-1, fmt, timespec);
- if (len > 0)
- break;
+ buf = sresize(buf, size, wchar_t);
+ ret = (int) wcsftime(buf, size, fmt, timespec);
+ } while (ret == 0);
+
+ rdadds(rs, buf+1);
+ sfree(buf);
+#else
+ char *buf = NULL;
+ wchar_t *cvtbuf;
+ char fmt[4];
+ int size, ret;
+
+ fmt[0] = ' ';
+ fmt[1] = '%';
+ fmt[2] = formatchr;
+ fmt[3] = '\0';
+
+ size = 0;
+ do {
+ size += USTRFTIME_DELTA;
+ buf = sresize(buf, size, char);
+ ret = (int) strftime(buf, size, fmt, timespec);
+ } while (ret == 0);
+
+ cvtbuf = ufroma_locale_dup(buf+1);
+ rdadds(rs, cvtbuf);
+ sfree(cvtbuf);
+ sfree(buf);
+#endif
+}
+
+wchar_t *ustrftime(const wchar_t *wfmt, const struct tm *timespec)
+{
+ rdstring rs = { 0, 0, NULL };
+
+ if (!wfmt)
+ wfmt = L"%c";
+
+ while (*wfmt) {
+ if (wfmt[0] == L'%' && wfmt[1] == L'%') {
+ rdadd(&rs, L'%');
+ wfmt += 2;
+ } else if (wfmt[0] == L'%' && wfmt[1]) {
+ ustrftime_internal(&rs, wfmt[1], timespec);
+ wfmt += 2;
+ } else {
+ rdadd(&rs, wfmt[0]);
+ wfmt++;
+ }