lib/barometer/data/local_datetime.rb in barometer-0.6.7 vs lib/barometer/data/local_datetime.rb in barometer-0.7.0

- old
+ new

@@ -68,16 +68,20 @@ elsif string.is_a?(Date) year = string.year month = string.mon day = string.day elsif string.is_a?(String) - datetime = Time.parse(string) - year = datetime.year - month = datetime.mon - day = datetime.day - hour = datetime.hour - min = datetime.min - sec = datetime.sec + begin + datetime = Time.parse(string) + year = datetime.year + month = datetime.mon + day = datetime.day + hour = datetime.hour + min = datetime.min + sec = datetime.sec + rescue ArgumentError + return nil + end end Data::LocalDateTime.new(year, month, day, hour, min, sec) end # convert to a Date class