108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/puppet/pops/time/timespan.rb', line 108
def self.parse(str, format = Format::DEFAULTS)
if format.is_a?(::Array)
format.each do |fmt|
fmt = FormatParser.singleton.parse_format(fmt) unless fmt.is_a?(Format)
begin
return fmt.parse(str)
rescue ArgumentError
end
end
raise ArgumentError, _("Unable to parse '%{str}' using any of the formats %{formats}") % { str: str, formats: format.join(', ') }
end
format = FormatParser.singleton.parse_format(format) unless format.is_a?(Format)
format.parse(str)
end
|