Class: QueryFilter::Utils::DateNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/query_filter/utils/date_normalizer.rb

Constant Summary collapse

TIME_FORMAT =
'%Y-%m-%d %H:%M:%S'
PG_MIN_YEAR =
-4713
PG_MAX_YEAR =
294276

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, format) ⇒ DateNormalizer

Returns a new instance of DateNormalizer.



10
11
12
13
14
# File 'lib/query_filter/utils/date_normalizer.rb', line 10

def initialize(date, format)
  @date = date
  @format = format
  @parsed_value = parse
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/query_filter/utils/date_normalizer.rb', line 8

def date
  @date
end

#formatObject (readonly)

Returns the value of attribute format.



8
9
10
# File 'lib/query_filter/utils/date_normalizer.rb', line 8

def format
  @format
end

Instance Method Details

#normalizeObject



16
17
18
# File 'lib/query_filter/utils/date_normalizer.rb', line 16

def normalize
  valid?(@parsed_value) ? @parsed_value : default_date
end