[#57574] [ruby-trunk - Feature #8976][Open] file-scope freeze_string directive — "akr (Akira Tanaka)" <akr@...>

70 messages 2013/10/02

[#57579] [ruby-trunk - Feature #8977][Open] String#frozen that takes advantage of the deduping — "sam.saffron (Sam Saffron)" <sam.saffron@...>

25 messages 2013/10/02

[#57679] [ruby-trunk - Feature #8987][Open] map/collect extension which handles arguments — "sowieso (So Wieso)" <sowieso@...>

16 messages 2013/10/05

[#57705] [ruby-trunk - Feature #8992][Open] Use String#freeze and compiler tricks to replace "str"f suffix — "headius (Charles Nutter)" <headius@...>

43 messages 2013/10/07

[#57727] [ruby-trunk - Feature #8998][Open] string keys for hash literals should use fstrings — "normalperson (Eric Wong)" <normalperson@...>

17 messages 2013/10/08

[#57771] [ruby-trunk - Bug #9008][Open] TestProcess#test_clock_getres_constants and TestProcess#test_clock_gettime_constants fails on ARM — "vo.x (Vit Ondruch)" <v.ondruch@...>

15 messages 2013/10/09

[#57888] [ruby-trunk - Feature #9025][Open] Clarify the error message when calling a method with the wrong number of arguments — Nerian (Gonzalo Rodríguez) <siotopo@...>

11 messages 2013/10/15

[#57993] [ruby-trunk - Feature #9047][Open] Alternate hash key syntax for symbols — "jamonholmgren (Jamon Holmgren)" <jamon@...>

13 messages 2013/10/23

[#58007] [ruby-trunk - Feature #9049][Open] Shorthands (a:b, *) for inclusive indexing — "mohawkjohn (John Woods)" <john.o.woods@...>

25 messages 2013/10/24

[#58033] [ruby-trunk - Bug #9053][Open] SSL Issue with Ruby 2.0.0 — "tisba (Sebastian Cohnen)" <ruby-lang@...>

16 messages 2013/10/25

[#58080] [ruby-trunk - Feature #9064][Open] Add support for packages, like in Java — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

23 messages 2013/10/30

[ruby-core:57695] [PATCH 2/2] datetime: fix strptime '%s %z'

From: Felipe Contreras <felipe.contreras@...>
Date: 2013-10-07 01:13:42 UTC
List: ruby-core #57695
From: Charlie Somerville <charliesome@ruby-lang.org>

Before:

  DateTime.strptime('0 +0100', '%s %z').strftime('%s %z')
  => "0 +0000"

After:

  DateTime.strptime('0 +0100', '%s %z').strftime('%s %z')
  => "0 +0100"

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 ext/date/date_core.c            | 8 ++++++--
 test/date/test_date_strptime.rb | 6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 5455630..5c84017 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -3686,12 +3686,17 @@ date_s_today(int argc, VALUE *argv, VALUE klass)
 static VALUE
 rt_rewrite_frags(VALUE hash)
 {
-    VALUE seconds;
+    VALUE seconds, offset;
 
     seconds = ref_hash("seconds");
     if (!NIL_P(seconds)) {
 	VALUE d, h, min, s, fr;
 
+	offset = ref_hash("offset");
+	if(!NIL_P(offset)) {
+	    seconds = f_add(seconds, offset);
+	}
+
 	d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
 	fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
 
@@ -3710,7 +3715,6 @@ rt_rewrite_frags(VALUE hash)
 	set_hash("sec", s);
 	set_hash("sec_fraction", fr);
 	del_hash("seconds");
-	del_hash("offset");
     }
     return hash;
 }
diff --git a/test/date/test_date_strptime.rb b/test/date/test_date_strptime.rb
index f8483f9..e37be57 100644
--- a/test/date/test_date_strptime.rb
+++ b/test/date/test_date_strptime.rb
@@ -308,6 +308,12 @@ class TestDateStrptime < Test::Unit::TestCase
 		 DateTime.strptime('2002-03-14T11:22:33.123456789-09:00', '%FT%T.%N%Z'))
   end
 
+  def test_strptime_bug_7445
+    d = DateTime.strptime('0 +0100', '%s %z')
+    assert_equal Rational(1, 24), d.offset
+    assert_equal 0, d.second
+  end
+
   def test_strptime__2
     n = 10**9
     (Date.new(2006,6,1)..Date.new(2007,6,1)).each do |d|
-- 
1.8.4-fc

In This Thread