lib/rufus/scheduler/util.rb in rufus-scheduler-3.0.9 vs lib/rufus/scheduler/util.rb in rufus-scheduler-3.1.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2006-2014, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2006-2015, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -44,35 +44,12 @@
def self.parse_in(o, opts={})
o.is_a?(String) ? parse_duration(o, opts) : o
end
- TZ_REGEX = /\b((?:[a-zA-Z][a-zA-z0-9\-+]+)(?:\/[a-zA-Z0-9_\-+]+)?)\b/
-
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
- t ? '' : m
- }
-
- begin
- DateTime.parse(o)
- rescue
- raise ArgumentError, "no time information in #{o.inspect}"
- end if RUBY_VERSION < '1.9.0'
-
- t = Time.parse(s)
-
- tz ? tz.local_to_utc(t) : t
+ Rufus::Scheduler::ZoTime.parse(o, opts).time
rescue StandardError => se
return nil if opts[:no_error]
raise se