Class: QueryStringInterface::Parsers::DateTimeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/query_string_interface/parsers/date_time_parser.rb

Constant Summary collapse

DATE_REGEX =
/^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?([ \t]*)(Z?|[-+\s]\d{2}?(:?\d{2})?))$/
ESCAPED_ZONE_REGEX =
/\s(\d{2}:\d{2})$/

Instance Method Summary collapse

Instance Method Details

#parse(value) ⇒ Object



11
12
13
14
# File 'lib/query_string_interface/parsers/date_time_parser.rb', line 11

def parse(value)
  value.gsub!(ESCAPED_ZONE_REGEX) { "+#{$1}" }
  Time.parse(value)
end

#parseable?(value, operator) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/query_string_interface/parsers/date_time_parser.rb', line 7

def parseable?(value, operator)
  DATE_REGEX.match(value)
end