Sha256: 98645274e8a473e71d12c98fd9d55b19ce4ca18839d5b5a6b24b9114591550af
Contents?: true
Size: 663 Bytes
Versions: 14
Compression:
Stored size: 663 Bytes
Contents
module HappyHelpers module Utils module DateParameterConverter class << self def convert!(params) params.each do |k, v| if looks_like_a_date?(v) params[k] = convert_to_date(v) elsif v.is_a? Hash convert!(v) end end end def looks_like_a_date?(v) v.is_a?(Hash) && v.has_key?('year') && v.has_key?('month') && v.has_key?('day') end def convert_to_date(v) DateTime.new(v['year'].to_i, v['month'].to_i, v['day'].to_i, v['hour'].to_i, v['minute'].to_i, v['second'].to_i) end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems