lib/rufus/scheduler/util.rb in rufus-scheduler-3.0.7 vs lib/rufus/scheduler/util.rb in rufus-scheduler-3.0.8

- old
+ new

@@ -29,13 +29,13 @@ #-- # time and string methods #++ - def self.parse(o) + def self.parse(o, opts={}) - opts = { :no_error => true } + opts[:no_error] = true parse_cron(o, opts) || parse_in(o, opts) || # covers 'every' schedule strings parse_at(o, opts) || raise(ArgumentError.new("couldn't parse \"#{o}\"")) @@ -50,10 +50,13 @@ def self.parse_at(o, opts={}) return o if o.is_a?(Time) + # TODO: deal with tz if suffixed to Chronic string? + return Chronic.parse(o, opts) if defined?(Chronic) + tz = nil s = o.to_s.gsub(TZ_REGEX) { |m| t = TZInfo::Timezone.get(m) rescue nil tz ||= t @@ -66,12 +69,10 @@ raise ArgumentError, "no time information in #{o.inspect}" end if RUBY_VERSION < '1.9.0' t = Time.parse(s) - t = tz.local_to_utc(t) if tz - - t + tz ? tz.local_to_utc(t) : t rescue StandardError => se return nil if opts[:no_error] raise se