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

Ticket #9137: dummy_time_parser_returns_nil.diff

File dummy_time_parser_returns_nil.diff, 1.2 kB (added by kampers, 1 year ago)
  • activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

    old new  
    124124        end 
    125125      end 
    126126 
     127      # Returns a +Time+ whose date component is set to a dummy value, to represent 
     128      # the value of database columns of type +time+. These column types 
     129      # usually store only time-of-day information, but Ruby has no such 
     130      # time-only type. 
     131      # 
     132      # Returns a +Time+ corresponding to the parsed time-of-day on January 1, 2000, 
     133      # with <tt>Base.default_timezone</tt> appended, or +nil+ if the string input 
     134      # cannot be parsed. 
    127135      def self.string_to_dummy_time(string) 
    128136        return string unless string.is_a?(String) 
    129137        return nil if string.empty? 
    130138        time_hash = Date._parse(string) 
     139        return nil if time_hash.empty? 
    131140        time_hash[:sec_fraction] = microseconds(time_hash) 
    132141        # pad the resulting array with dummy date information 
    133142        time_array = [2000, 1, 1]