#include <msvcrt/stdlib.h>
#include <msvcrt/wchar.h>
+
#define TM_YEAR_BASE 1900
static const char *afmt[] = {
static size_t gsize;
static char *pt;
-static int
-_add(const char *str)
+
+static int _add(const char* str)
{
for (;; ++pt, --gsize)
{
}
}
-static int
-_conv(int n, int digits, char pad)
+static int _conv(int n, int digits, char pad)
{
static char buf[10];
char *p;
return _add(++p);
}
-static size_t
-_fmt(const char *format, const struct tm *t)
+static size_t _fmt(const char* format, const struct tm* t)
{
for (; *format; ++format)
{
if (*format == '%') {
if (*(format+1) == '#' ) {format++;}
- switch(*++format)
- {
+ switch(*++format) {
case '\0':
--format;
break;
return 0;
continue;
case 'I':
- if (!_conv(t->tm_hour % 12 ?
- t->tm_hour % 12 : 12, 2, '0'))
+ if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, '0'))
return 0;
continue;
case 'j':
return 0;
continue;
case 'l':
- if (!_conv(t->tm_hour % 12 ?
- t->tm_hour % 12 : 12, 2, ' '))
+ if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, ' '))
return 0;
continue;
case 'M':
return 0;
continue;
case 'U':
- if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
- 2, '0'))
+ if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, 2, '0'))
return 0;
continue;
case 'W':
- if (!_conv((t->tm_yday + 7 -
- (t->tm_wday ? (t->tm_wday - 1) : 6))
- / 7, 2, '0'))
+ if (!_conv((t->tm_yday + 7 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7, 2, '0'))
return 0;
continue;
case 'w':
return 0;
continue;
case 'y':
- if (!_conv((t->tm_year + TM_YEAR_BASE)
- % 100, 2, '0'))
+ if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, 2, '0'))
return 0;
continue;
case 'Y':
return 0;
}
-size_t
-wcsftime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tm *t)
+size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const struct tm* t)
{
char *x;
char *f;
pt = x;
if ((gsize = maxsize) < 1)
return 0;
- if (_fmt(f, t))
- {
+ if (_fmt(f, t)) {
*pt = '\0';
free(f);
for(i=0;i<maxsize;i++)