title: converting a hours from a time stamp into a hash listing the hour and frequency in Ruby
body: <p>Ok, so I'm pretty new at this, I hope I explain this correctly. I'm using Ruby, and I have a program which takes a CSV file and performs some various functions on it. What I'm concerned with here is the TIME portion. I took a column of data which was a string, and used this method to convert it to DateTime and give me just the hour part:</p>
  
  <pre><code>def hour_reg(regdate)
    regdate.to_s
    time_stamp = DateTime.strptime("#{regdate}", "%m/%d/%y %H:%M").hour
    time_stamp
  end
  </code></pre>
  
  <p>that part works fine. so now I'm trying to take that HOUR that I just got, and convert that into a HASH which displays the Hour of the day (1 through 24), and how many times each hour comes up. For example, if the hour 1 came up (for 1AM) 3 separate times, it would display: {1 => 3} in the hash. here's what the code looks like that iterates through the column of TIMES, indicated by ":regdate"</p>
  
  <pre><code>contents.each do |row|
    id = row[0]
    name = row[:first_name]
    zipcode = clean_zipcode(row[:zipcode])
    **reg_time = hour_reg(row[:regdate])**
  end
  </code></pre>
  
  <p>Basically I want the frequency of each hour. can anyone help with this? I'm having a great deal of trouble</p>