Module: Activite::Utils

Defined in:
lib/activite/utils.rb

Class Method Summary collapse

Class Method Details

.normalize_date_params(options) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/activite/utils.rb', line 6

def self.normalize_date_params(options)
  opts = hash_with_string_date_keys(options)

  convert_epoch_date_params!(opts)
  convert_ymd_date_params!(opts)

  if opts.has_key? 'startdateymd' and !opts.has_key? 'startdate'
    opts['startdate'] = to_epoch(opts['startdateymd'])
  end
  if opts.has_key? 'enddateymd' and !opts.has_key? 'enddate'
    opts['enddate'] = to_epoch(opts['enddateymd'])
  end

  opts['startdateymd'] = to_ymd(opts['startdate'])      if opts.has_key? 'startdate'
  opts['enddateymd']   = to_ymd(opts['enddate'])        if opts.has_key? 'enddate'
  opts
end