Browse files

added docs to String#to_date

  • Loading branch information...
1 parent 7bf6edf commit 53cc85fad3440d5817ecf7e0e8cd0c7ff3d9a062 Francesco Rodriguez committed May 11, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 activesupport/lib/active_support/core_ext/string/conversions.rb
View
6 activesupport/lib/active_support/core_ext/string/conversions.rb
@@ -15,6 +15,12 @@ def to_time(form = :utc)
end
end
+ # Converts a string to a Date value.
+ #
+ # "1-1-2012".to_date #=> Sun, 01 Jan 2012
+ # "01/01/2012".to_date #=> Sun, 01 Jan 2012
+ # "2012-12-13".to_date #=> Thu, 13 Dec 2012
+ # "12/13/2012".to_date #=> ArgumentError: invalid date
def to_date
unless blank?
date_values = ::Date._parse(self, false).values_at(:year, :mon, :mday)

0 comments on commit 53cc85f

Please sign in to comment.