summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'time.c')
-rw-r--r--time.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/time.c b/time.c
index bdb0dba970..34a90977ab 100644
--- a/time.c
+++ b/time.c
@@ -31,10 +31,6 @@
# include <sys/time.h>
#endif
-#if defined(HAVE_LOCALE_H)
-# include <locale.h>
-#endif
-
#include "id.h"
#include "internal.h"
#include "internal/array.h"
@@ -956,11 +952,7 @@ zone_str(const char *zone)
str = rb_usascii_str_new(zone, len);
}
else {
-#if defined(_WIN32)
- str = rb_utf8_str_new(zone, len);
-#else
str = rb_enc_str_new(zone, len, rb_locale_encoding());
-#endif
}
return rb_fstring(str);
}
@@ -1659,25 +1651,11 @@ localtime_with_gmtoff_zone(const time_t *t, struct tm *result, long *gmtoff, VAL
if (zone) {
#if defined(HAVE_TM_ZONE)
*zone = zone_str(tm.tm_zone);
-#elif defined(_WIN32)
- {
- enum {tz_name_max = 32}; /* numberof(TIME_ZONE_INFORMATION::StandardName) */
- WCHAR wbuf[tz_name_max + 1];
- char cbuf[tz_name_max * 4 + 1];
- size_t wlen = wcsftime(wbuf, numberof(wbuf), L"%Z", &tm);
- DWORD clen = 0;
- if (wlen > 0 && wlen < numberof(wbuf)) {
- clen = WideCharToMultiByte(CP_UTF8, 0, wbuf, wlen, cbuf, sizeof(cbuf), NULL, NULL);
- }
- if (clen > 0 && clen < sizeof(cbuf)) {
- cbuf[clen] = '\0';
- *zone = zone_str(cbuf);
- }
- else {
- *zone = zone_str(NULL);
- }
- }
#elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT)
+# if defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 140
+# define tzname _tzname
+# define daylight _daylight
+# endif
/* this needs tzset or localtime, instead of localtime_r */
*zone = zone_str(tzname[daylight && tm.tm_isdst]);
#else