# File lib/rbot/core/utils/parse_time.rb, line 160 def Utils.parse_time_offset(str) case str when /^(\d+):(\d+)(?:\:(\d+))?$/ # TODO refactor hour = $1.to_i min = $2.to_i sec = $3.to_i now = Time.now later = Time.mktime(now.year, now.month, now.day, hour, min, sec) # if the given hour is earlier than current hour, given timestr # must have been meant to be in the future if hour < now.hour || hour <= now.hour && min < now.min later += 60*60*24 end return later - now when /^(\d+):(\d+)(am|pm)$/ # TODO refactor hour = $1.to_i min = $2.to_i ampm = $3 if ampm == "pm" hour += 12 end now = Time.now later = Time.mktime(now.year, now.month, now.day, hour, min, now.sec) return later - now else ParseTime.parse_period(str) end end
Generated with the Darkfish Rdoc Generator 2.