Method: Excite::Postprocessor#normalize_date

Defined in:
lib/excite/postprocessor.rb

#normalize_date(hsh) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/excite/postprocessor.rb', line 121

def normalize_date(hsh)
  str = hsh['date']
  if str =~ /(\d{4})/
    year = $1.to_i
    current_year = Time.now.year
    if year <= current_year+3
      ret = year
      hsh['year'] = ret
    else
      ret = nil
    end
  end
  hsh['date'] = ret
  hsh
end