def self.parse(str, opts={})
if defined?(::Chronic) && t = ::Chronic.parse(str, opts)
return ZoTime.new(t, nil)
end
begin
DateTime.parse(str)
rescue
fail ArgumentError, "no time information in #{str.inspect}"
end
zone = nil
s =
str.gsub(/\S+/) do |w|
if z = get_tzone(w)
zone ||= z
''
else
w
end
end
local = Time.parse(s)
izone = extract_iso8601_zone(s)
zone ||=
if s.match(/\dZ\b/)
get_tzone('Zulu')
elsif izone
get_tzone(izone)
elsif local.zone.nil? && izone
get_tzone(local.strftime('%:z'))
else
get_tzone(:local)
end
secs =
if izone
local.to_f
else
zone.period_for_local(local).to_utc(local).to_f
end
ZoTime.new(secs, zone)
end