summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-07 06:17:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-07 06:17:38 +0000
commite382f7f00ebf19497c4956ef7744381eba875d43 (patch)
treef9dee51af838313ab8b7b619668537455a334072
parent50ef220b5a60260dd44d994a99f2baee9f8582f4 (diff)
* lib/date/format.rb: specify maximum number of digits to parse
"200608007". %Y(4), %y(2), %m(2), %d(2). [ruby-core:8484] [experimental] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/date/format.rb8
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 06b4001dbb1..b0863e082f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Aug 7 14:51:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/date/format.rb: specify maximum number of digits to parse
+ "200608007". %Y(4), %y(2), %m(2), %d(2). [ruby-core:8484]
+ [experimental]
+
Mon Aug 7 14:37:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in, common.mk: AIX link issue. a patch from Yutaka
diff --git a/lib/date/format.rb b/lib/date/format.rb
index 4425635d333..8533e8461d1 100644
--- a/lib/date/format.rb
+++ b/lib/date/format.rb
@@ -75,7 +75,7 @@ class Date
when '%D'
return unless __strptime(str, '%m/%d/%y', elem)
when '%d', '%e'
- return unless str.sub!(/\A ?(\d+)/o, '')
+ return unless str.sub!(/\A ?(\d{1,2})/o, '')
val = $1.to_i
return unless (1..31) === val
elem[:mday] = val
@@ -112,7 +112,7 @@ class Date
return unless (0..59) === val
elem[:min] = val
when '%m'
- return unless str.sub!(/\A(\d+)/o, '')
+ return unless str.sub!(/\A(\d{1,2})/o, '')
val = $1.to_i
return unless (1..12) === val
elem[:mon] = val
@@ -171,11 +171,11 @@ class Date
when '%x'
return unless __strptime(str, '%m/%d/%y', elem)
when '%Y'
- return unless str.sub!(/\A([-+]?\d+)/o, '')
+ return unless str.sub!(/\A([-+]?\d{1,4})/o, '')
val = $1.to_i
elem[:year] = val
when '%y'
- return unless str.sub!(/\A(\d+)/o, '')
+ return unless str.sub!(/\A(\d{2})/o, '')
val = $1.to_i
return unless (0..99) === val
elem[:year] = val