Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require_gem 'activesupport'
- require 'active_support'
- require 'date'
- class String
- def time_string_parse
- time_string = downcase.strip.gsub(/\s+/, ' ')
- time = Time.now
- case time_string
- when /\btomorrow\b/
- time += 86400
- end
- case time_string
- when /\bat (\d+)(am|pm)\b/
- time = Time.local(time.year, time.month, time.day, $1.to_i + ($2 == 'pm' ? 12 : 0), 0, 0)
- end
- time
- end
- end
Add Comment
Please, Sign In to add comment