{
struct tm tv;
time_t t;
-#if HAVE_TM_GMTOFF
- struct tm *tp;
-#endif
if (0 == strcasecmp ("end of time", fancy_time))
{
return GNUNET_SYSERR;
t = mktime (&tv);
atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
-#if HAVE_TM_GMTOFF
- tp = localtime (&t);
- atime->abs_value_us += 1000LL * 1000LL * tp->tm_gmtoff;
-#elif defined LINUX
- atime->abs_value_us -= 1000LL * 1000LL * timezone;
-#elif defined WINDOWS
- {
- DWORD tzv;
- TIME_ZONE_INFORMATION tzi;
- tzv = GetTimeZoneInformation (&tzi);
- if (TIME_ZONE_ID_INVALID != tzv)
- {
- atime->abs_value_us -= 1000LL * 1000LL * tzi.Bias * 60LL;
- }
- }
-#endif
return GNUNET_OK;
}
if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
return _("end of time");
tt = t.abs_value_us / 1000LL / 1000LL;
- tp = gmtime (&tt);
+ tp = localtime (&tt);
+ /* This is hacky, but i don't know a way to detect libc character encoding.
+ * Just expect utf8 from glibc these days.
+ * As for msvcrt, use the wide variant, which always returns utf16
+ * (otherwise we'd have to detect current codepage or use W32API character
+ * set conversion routines to convert to UTF8).
+ */
+#ifndef WINDOWS
strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", tp);
+#else
+ {
+ static wchar_t wbuf[255];
+ uint8_t *conved;
+ size_t ssize;
+
+ wcsftime (wbuf, sizeof (wbuf) / sizeof (wchar_t),
+ L"%a %b %d %H:%M:%S %Y", tp);
+
+ ssize = sizeof (buf);
+ conved = u16_to_u8 (wbuf, sizeof (wbuf) / sizeof (wchar_t),
+ (uint8_t *) buf, &ssize);
+ if (conved != (uint8_t *) buf)
+ {
+ strncpy (buf, (char *) conved, sizeof (buf));
+ buf[255 - 1] = '\0';
+ free (conved);
+ }
+ }
+#endif
return buf;
}
/**
* Makes a copy of argv that consists of a single memory chunk that can be
- * freed with a single call to GNUNET_free ();
+ * freed with a single call to GNUNET_free();
*/
static char *const *
_make_continuous_arg_copy (int argc,
* other than W32.
* Returned argv has u8argv[u8argc] == NULL.
* Returned argv is a single memory block, and can be freed with a single
- * GNUNET_free () call.
+ * GNUNET_free() call.
*
* @param argc argc (as given by main())
* @param argv argv (as given by main())