From 33356ff75b3c33f85aa21707e2e23bcba0fe7c17 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 22 Nov 2010 05:25:15 +0000 Subject: * time.c (time_zone): use rb_locale_str_new_cstr to set encoding as locale and convert its content to internal encoding. [ruby-core:33278] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_time.rb | 2 ++ time.c | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a74d01e01..c001a3444e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Nov 22 14:22:45 2010 NARUSE, Yui + + * time.c (time_zone): use rb_locale_str_new_cstr to set encoding + as locale and convert its content to internal encoding. + [ruby-core:33278] + Mon Nov 22 11:58:11 2010 NARUSE, Yui * string.c (rb_str_concat): set ENC_CODERANGE_VALID when the diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 95d36c597f..83f5907f99 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -465,6 +465,7 @@ class TestTime < Test::Unit::TestCase assert_equal(1, T2000.yday) assert_equal(false, T2000.isdst) assert_equal("UTC", T2000.zone) + assert_equal(Encoding.find("locale"), T2000.zone.encoding) assert_equal(0, T2000.gmt_offset) assert(!T2000.sunday?) assert(!T2000.monday?) @@ -486,6 +487,7 @@ class TestTime < Test::Unit::TestCase assert_equal(t.yday, Time.at(946684800).yday) assert_equal(t.isdst, Time.at(946684800).isdst) assert_equal(t.zone, Time.at(946684800).zone) + assert_equal(Encoding.find("locale"), Time.at(946684800).zone.encoding) assert_equal(t.gmt_offset, Time.at(946684800).gmt_offset) assert_equal(t.sunday?, Time.at(946684800).sunday?) assert_equal(t.monday?, Time.at(946684800).monday?) diff --git a/time.c b/time.c index bd9ca1b7ba..5ed11c6cee 100644 --- a/time.c +++ b/time.c @@ -4189,11 +4189,11 @@ time_zone(VALUE time) MAKE_TM(time, tobj); if (TIME_UTC_P(tobj)) { - return rb_str_new2("UTC"); + return rb_obj_untaint(rb_locale_str_new_cstr("UTC")); } if (tobj->vtm.zone == NULL) return Qnil; - return rb_str_new2(tobj->vtm.zone); + return rb_obj_untaint(rb_locale_str_new_cstr(tobj->vtm.zone)); } /* -- cgit v1.2.3