The Date class calls the self.parse method to parse the provided string before the date.
1.9.2p320 :051 > x = Date.parse('2011-31-12') ArgumentError: invalid date from .../rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/date.rb:1022:in `new_by_frags' from .../rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/date.rb:1066:in `parse'
which turns the self call into the _parse method, which is located in the file "... / ruby-1.9.2-p320 / lib / ruby โโ/1.9.1/date/format.rb".
it calls the strftime function ("def strftime (fmt = '% F')"), where the default format for generating the date is "% F", which according to the documentation of the temporary class "% F is the date ISO 8601 format (% Y-% m-% d) ".
prasad.surase
source share