Check return value of `to_date`

This commit is contained in:
Pat Hawks 2016-12-22 16:15:09 -06:00
parent 2eb8469936
commit f7edcceb70
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
1 changed files with 4 additions and 4 deletions

View File

@ -347,12 +347,12 @@ module Jekyll
private
def time(input)
begin
Liquid::Utils.to_date(input).to_time
rescue NoMethodError
date = Liquid::Utils.to_date(input)
unless date.respond_to?(:strftime)
raise Errors::InvalidDateError,
"Invalid Date: '#{input.inspect}' is not a valid datetime."
end.localtime
end
date.to_time.localtime
end
private