class Newgistics::TimeParsers::AmericanDatetime
Constants
- DATE_FORMAT
Public Instance Methods
parse(string)
click to toggle source
# File lib/newgistics/time_parsers/american_datetime.rb, line 6 def parse(string) date = date_with_timezone(string) parse_date(date, string) end
Private Instance Methods
date_with_timezone(string)
click to toggle source
# File lib/newgistics/time_parsers/american_datetime.rb, line 13 def date_with_timezone(string) return string if includes_timezone?(string) "#{string} #{Newgistics.time_zone.utc_offset}" end
includes_timezone?(string)
click to toggle source
# File lib/newgistics/time_parsers/american_datetime.rb, line 18 def includes_timezone?(string) string =~ /[+-]\d{2}:\d{2}\z/ end
parse_date(date, fallback)
click to toggle source
# File lib/newgistics/time_parsers/american_datetime.rb, line 22 def parse_date(date, fallback) Time.strptime(date, DATE_FORMAT). getlocal(Newgistics.local_time_zone.utc_offset) rescue ArgumentError fallback end