summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-31 14:06:50 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-31 14:06:50 +0000
commit53293d3c627ac25ff2978859dabeaca14a6fe7b7 (patch)
treed5fe262d73e52897882aa0e5e53f6e03eb59e106
parent97a5506fd5b0559977944f6e907ae9bac3a21ca4 (diff)
merge revision(s) 43177,43191: [Backport #8991]
* lib/time.rb (Time.strptime): Use :offset. Patch by Felipe Contreras. [ruby-core:57694] * lib/time.rb (Time.strptime): Time.strptime('0', '%s') returns local time Time object as Ruby 2.0 and before. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@43483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--lib/time.rb6
-rw-r--r--test/test_time.rb2
-rw-r--r--version.h2
4 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 27f6c79c57..3f52eba826 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Oct 31 23:05:33 2013 Tanaka Akira <akr@fsij.org>
+
+ * lib/time.rb (Time.strptime): Time.strptime('0', '%s') returns local
+ time Time object as Ruby 2.0 and before.
+
+Thu Oct 31 23:05:33 2013 Tanaka Akira <akr@fsij.org>
+
+ * lib/time.rb (Time.strptime): Use :offset.
+ Patch by Felipe Contreras. [ruby-core:57694]
+
Thu Oct 31 22:49:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_close_read): duplex IO should wait its child process
diff --git a/lib/time.rb b/lib/time.rb
index 1663af8e76..40b28d9085 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -282,7 +282,11 @@ class Time
d = Date._strptime(date, format)
raise ArgumentError, "invalid strptime format - `#{format}'" unless d
if seconds = d[:seconds]
- Time.at(seconds)
+ if offset = d[:offset]
+ Time.at(seconds).localtime(offset)
+ else
+ Time.at(seconds)
+ end
else
year = d[:year]
year = yield(year) if year && block_given?
diff --git a/test/test_time.rb b/test/test_time.rb
index 9dbce3f654..df6bbfd20c 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -393,6 +393,8 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
def test_strptime
assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z"))
assert_equal(Time.at(1).localtime, Time.strptime("1", "%s"))
+ assert_equal(false, Time.strptime('0', '%s').utc?)
+ assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset)
end
def test_nsec
diff --git a/version.h b/version.h
index 4fbc097984..8a0b5c33ef 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 471
+#define RUBY_PATCHLEVEL 472
#define RUBY_RELEASE_DATE "2013-10-31"
#define RUBY_RELEASE_YEAR 2013