Class: Pipio::TimeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pipio/time_parser.rb

Constant Summary collapse

NO_DATE =
/\A\d{1,2}:\d{1,2}:\d{1,2}(?: [AP]M)?\Z/
UNPARSEABLE_BY_DATETIME_PARSE =

01/22/2008 03:01:45 PM

'%m/%d/%Y %I:%M:%S %P'

Instance Method Summary collapse

Constructor Details

#initialize(year, month, day) ⇒ TimeParser

Returns a new instance of TimeParser.



8
9
10
# File 'lib/pipio/time_parser.rb', line 8

def initialize(year, month, day)
  @fallback_date_string = "#{year}-#{month}-#{day}"
end

Instance Method Details

#parse(timestamp) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/pipio/time_parser.rb', line 12

def parse(timestamp)
  if timestamp
    if has_no_date?(timestamp)
      parse_with_date(@fallback_date_string + " " + timestamp)
    else
      parse_with_date(timestamp)
    end
  end
end