Class: TimePup::DateTimeParser
- Inherits:
-
Object
- Object
- TimePup::DateTimeParser
- Defined in:
- lib/time_pup/date_time_parser.rb
Constant Summary collapse
- MONTHS =
/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i
- TIME =
/\d{1,4}[a|p]m/i
Class Method Summary collapse
Class Method Details
.parse(parsable, timezone = 'UTC') ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/time_pup/date_time_parser.rb', line 6 def self.parse(parsable, timezone = 'UTC') return nil unless parsable.match(MONTHS) date = DateTime.parse(parsable).to_time date = date.in_time_zone(ActiveSupport::TimeZone[timezone]) time = find_time(parsable) if time date.change(hour: time.hour, min: time.min).utc else date.change(hour: 8).utc end end |