diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-09-28 23:17:07 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-09-28 23:17:07 +0530 |
commit | 955a72c692a4298d238cc2e6353b9874099203f1 (patch) | |
tree | 2a05fecd15526cd0013c22e45825be1aca4844d9 /activesupport/lib/active_support/core_ext/string/conversions.rb | |
parent | 77fbe1c0199567486c422fdf5cce49f2c11fc953 (diff) | |
parent | cf3e760b87c49470c9a26ab3e2da67602474be1f (diff) | |
download | rails-955a72c692a4298d238cc2e6353b9874099203f1.tar.gz rails-955a72c692a4298d238cc2e6353b9874099203f1.tar.bz2 rails-955a72c692a4298d238cc2e6353b9874099203f1.zip |
Merge branch 'master' of github.com:lifo/docrails
Conflicts:
actionpack/lib/action_view/helpers/asset_tag_helper.rb
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/conversions.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/conversions.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/conversions.rb b/activesupport/lib/active_support/core_ext/string/conversions.rb index 022b376aec..9b9d83932e 100644 --- a/activesupport/lib/active_support/core_ext/string/conversions.rb +++ b/activesupport/lib/active_support/core_ext/string/conversions.rb @@ -2,7 +2,17 @@ require 'date' require 'active_support/core_ext/time/calculations' class String - # Form can be either :utc (default) or :local. + # Converts a string to a Time value. + # The +form+ can be either :utc or :local (default :utc). + # + # The time is parsed using Date._parse method. + # If +form+ is :local, then time is formatted using Time.zone + # + # "3-2-2012".to_time # => 2012-02-03 00:00:00 UTC + # "12:20".to_time # => ArgumentError: invalid date + # "2012-12-13 06:12".to_time # => 2012-12-13 06:12:00 UTC + # "2012-12-13T06:12".to_time # => 2012-12-13 06:12:00 UTC + # "2012-12-13T06:12".to_time(:local) # => 2012-12-13 06:12:00 +0100 def to_time(form = :utc) unless blank? date_values = ::Date._parse(self, false). |