summaryrefslogtreecommitdiff
path: root/lib/date/format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/date/format.rb')
-rw-r--r--lib/date/format.rb8
1 files changed, 4 insertions, 4 deletions
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