Take advantage of Liquid::Utils.to_date

This commit is contained in:
Pat Hawks 2016-12-22 14:39:08 -06:00
parent 7862f731b6
commit c42eb7fc3a
1 changed files with 3 additions and 10 deletions

View File

@ -345,16 +345,9 @@ module Jekyll
private
def time(input)
case input
when Time
input.clone
when Date
input.to_time
when String
Time.parse(input) rescue Time.at(input.to_i)
when Numeric
Time.at(input)
else
begin
Liquid::Utils.to_date(input).to_time
rescue NoMethodError
raise Errors::InvalidDateError,
"Invalid Date: '#{input.inspect}' is not a valid datetime."
end.localtime