8000 Win32: Defer change of timezone name encoding after 3.4 · github/ruby@fb82f3a · GitHub
[go: up one dir, main page]

Skip to content

Commit fb82f3a

Browse files
committed
Win32: Defer change of timezone name encoding after 3.4
This change will be merged into 3.5 along with other encoding, command line, environment variables, etc. Revert following commits: - bd831bc [Bug #20929] Win32: Use `wcsftime` - 1c15f64 [Bug #20929] Win32: Encode timezone name in UTF-8 - 78762b5 [Bug #20929] Fix `assert_zone_encoding`
1 parent 42026ec commit fb82f3a

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

test/ruby/test_time.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,15 +717,13 @@ def test_inspect
717717
assert_equal("2000-01-01 09:12:34 +091234", t2000.localtime(9*3600+12*60+34).inspect)
718718
end
719719

720-
FIXED_ZONE_ENCODING = (Encoding::UTF_8 if /mswin|mingw/.match?(RUBY_PLATFORM))
721-
722720
def assert_zone_encoding(time)
723721
zone = time.zone
724722
assert_predicate(zone, :valid_encoding?)
725723
if zone.ascii_only?
726724
assert_equal(Encoding::US_ASCII, zone.encoding)
727725
else
728-
enc = FIXED_ZONE_ENCODING || Encoding.find('locale')
726+
enc = Encoding.default_internal || Encoding.find('locale')
729727
assert_equal(enc, zone.encoding)
730728
end
731729
end

time.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
# include <sys/time.h>
3232
#endif
3333

34-
#if defined(HAVE_LOCALE_H)
35-
# include <locale.h>
36-
#endif
37-
3834
#include "id.h"
3935
#include "internal.h"
4036
#include "internal/array.h"
@@ -956,11 +952,7 @@ zone_str(const char *zone)
956952
str = rb_usascii_str_new(zone, len);
957953
}
958954
else {
959-
#if defined(_WIN32)
960-
str = rb_utf8_str_new(zone, len);
961-
#else
962955
str = rb_enc_str_new(zone, len, rb_locale_encoding());
963-
#endif
964956
}
965957
return rb_fstring(str);
966958
}
@@ -1659,25 +1651,11 @@ localtime_with_gmtoff_zone(const time_t *t, struct tm *result, long *gmtoff, VAL
16591651
if (zone) {
16601652
#if defined(HAVE_TM_ZONE)
16611653
*zone = zone_str(tm.tm_zone);
1662-
#elif defined(_WIN32)
1663-
{
1664-
enum {tz_name_max = 32}; /* numberof(TIME_ZONE_INFORMATION::StandardName) */
1665-
WCHAR wbuf[tz_name_max + 1];
1666-
char cbuf[tz_name_max * 4 + 1];
1667-
size_t wlen = wcsftime(wbuf, numberof(wbuf), L"%Z", &tm);
1668-
DWORD clen = 0;
1669-
if (wlen > 0 && wlen < numberof(wbuf)) {
1670-
clen = WideCharToMultiByte(CP_UTF8, 0, wbuf, wlen, cbuf, sizeof(cbuf), NULL, NULL);
1671-
}
1672-
if (clen > 0 && clen < sizeof(cbuf)) {
1673-
cbuf[clen] = '\0';
1674-
*zone = zone_str(cbuf);
1675-
}
1676-
else {
1677-
*zone = zone_str(NULL);
1678-
}
1679-
}
16801654
#elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT)
1655+
# if defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 140
1656+
# define tzname _tzname
1657+
# define daylight _daylight
1658+
# endif 8E32
16811659
/* this needs tzset or localtime, instead of localtime_r */
16821660
*zone = zone_str(tzname[daylight && tm.tm_isdst]);
16831661
#else

win32/Makefile.sub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
785785
#define HAVE_STRUCT_TIMEVAL 1
786786
!if $(MSC_VER) >= 1900
787787
#define HAVE_STRUCT_TIMESPEC
788-
#define HAVE_LOCALE_H 1
789788
!endif
790789
!if $(MSC_VER) >= 1600
791790
#define HAVE_INTTYPES_H 1

0 commit comments

Comments
 (0)
0