* ext/date/lib/date/format.rb (_iso8601): added a pattern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2011-04-24 18:07:24 +00:00
parent f3551c0476
commit 9f103e659e
2 changed files with 20 additions and 11 deletions

View File

@ -1,3 +1,7 @@
Mon Apr 25 03:04:16 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/lib/date/format.rb (_iso8601): added a pattern.
Mon Apr 25 02:51:22 2011 NARUSE, Yui <naruse@ruby-lang.org>
* ext/date/lib/date/format.rb: require 'date_core.so'.
@ -6,7 +10,7 @@ Mon Apr 25 02:51:22 2011 NARUSE, Yui <naruse@ruby-lang.org>
Mon Apr 25 02:47:46 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/lib/date/format.rb: fixed a bug of regex.
* ext/date/lib/date/format.rb (_iso8601): fixed a bug of regex.
Mon Apr 25 02:12:26 2011 Tadayoshi Funaba <tadf@dotrb.org>

View File

@ -209,7 +209,8 @@ class Date
elsif /\A\s*(?:([-+]?(?:\d{4}|\d{2})|--)(\d{2})(\d{2})|
([-+]?(?:\d{4}|\d{2}))?(\d{3})|
-(\d{3})|
(\d{4}|\d{2})?w(\d{2})(\d))
(\d{4}|\d{2})?w(\d{2})(\d)|
-w-(\d))
(?:t?
(\d{2})(\d{2})(?:(\d{2})(?:[,.](\d+))?)?
(z|[-+]\d{2}(?:\d{2})?)?)?\s*\z/ix =~ str
@ -252,18 +253,22 @@ class Date
end
e[:cwyear] = y
end
elsif $10
e = {
:cwday => $10.to_i
}
end
if $10
e[:hour] = $10.to_i
e[:min] = $11.to_i
e[:sec] = $12.to_i if $12
end
if $13
e[:sec_fraction] = Rational($13.to_i, 10**$13.size)
if $11
e[:hour] = $11.to_i
e[:min] = $12.to_i
e[:sec] = $13.to_i if $13
end
if $14
e[:zone] = $14
e[:offset] = zone_to_diff($14)
e[:sec_fraction] = Rational($14.to_i, 10**$14.size)
end
if $15
e[:zone] = $15
e[:offset] = zone_to_diff($15)
end
e
elsif /\A\s*(?:(\d{2}):(\d{2})(?::(\d{2})(?:[,.](\d+))?)?