Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10369: documentation_for_datetime_formatting_follow_time_date.2.patch

File documentation_for_datetime_formatting_follow_time_date.2.patch, 1.7 kB (added by revans, 1 year ago)
  • vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb

    old new  
    1111            alias_method :inspect, :readable_inspect 
    1212          end 
    1313        end 
    14  
     14         
     15        # Convert to a formatted string - see DATE_FORMATS for predefined formats. 
     16        # You can also add your own formats to the DATE_FORMATS constant and use them with this method. 
     17        #  
     18        # This method is also aliased as <tt>to_s</tt>. 
     19        #  
     20        # === Examples: 
     21        # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0)   # => "Tue, 04 Dec 2007 00:00:00 +0000" 
     22        #  
     23        #   datetime.to_formatted_s(:db)            # => "2007-12-04 00:00:00" 
     24        #   datetime.to_s(:db)                      # => "2007-12-04 00:00:00" 
     25        #   datetime.to_formatted_s(:short)         # => "04 Dec 00:00" 
     26        #   datetime.to_formatted_s(:long)          # => "December 04, 2007 00:00" 
     27        #   datetime.to_formatted_s(:long_ordinal)  # => "December 4th, 2007 00:00" 
     28        #   datetime.to_formatted_s(:rfc822)        # => "Tue, 04 Dec 2007 00:00:00 +0000" 
     29        # 
    1530        def to_formatted_s(format = :default) 
    1631          if formatter = ::Time::DATE_FORMATS[format] 
    1732            if formatter.respond_to?(:call) 
     
    4560          self 
    4661        end 
    4762         
     63        # Converts datetime to an appropriate format for use in XML 
    4864        def xmlschema 
    4965          strftime("%Y-%m-%dT%H:%M:%S#{offset == 0 ? 'Z' : '%Z'}") 
    5066        end