mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
50ef220b5a
commit
e382f7f00e
2 changed files with 10 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue