Issue #7137 has been updated by garysweaver (Gary Weaver).


I respectfully ask to reopen this ticket. The problem is that people expect that Date.parse('Monitoring') to fail or return nil because it isn't a date nor does it contain anything that *should* be interpreted as a date. The problem was *not* the one that Alexey last stated (Date.parse('10/11/12')) which was the stated reason for closing this ticket by @tadf, although I appreciate his help.

@tadf, I understand that @matz's solution was to use a pattern matching solution and that this was fastest, but I do not believe that Date.parse('Monitoring') should return Monday. and wonder if @matz agrees? Those new to Ruby will use this method thinking that it will work properly, so it would be more helpful if the method were either called Date.guess('Monitoring') or if instead Date.parse were deprecated or flagged compiler warning and in the deprecation or warning message tell people to use strptime instead because Date.parse is too lenient.

Thanks in advance again for considering this change! You guys are awesome!

Gary
----------------------------------------
Bug #7137: Date.parse overly lenient when attempting to parse Monday?
https://bugs.ruby-lang.org/issues/7137#change-30768

Author: garysweaver (Gary Weaver)
Status: Rejected
Priority: Low
Assignee: tadf (tadayoshi funaba)
Category: lib
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.parse('Monitoring')
=> #<Date: 2012-10-08 ((2456209j,0s,0n),+0s,2299161j)>
irb(main):003:0> Object.constants.sort.each{|c|puts "#{c}=#{Object.const_get(c)}" if c.to_s.start_with? 'RUBY'}; nil
RUBY_COPYRIGHT=ruby - Copyright (C) 1993-2012 Yukihiro Matsumoto
RUBY_DESCRIPTION=ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
RUBY_ENGINE=ruby
RUBY_PATCHLEVEL=194
RUBY_PLATFORM=x86_64-linux
RUBY_RELEASE_DATE=2012-04-20
RUBY_REVISION=35410
RUBY_VERSION=1.9.3
=> nil

It's nice that it tries to make sense out of strings liberally, but turning "Monitoring" into "Monday" seems a bit too lenient. Understand the workaround is not to use Date.parse, but I think this is buggy.

Thanks!


-- 
http://bugs.ruby-lang.org/