Refactor date filter to accept "Time types" other than Date, Time, and DateTime. For example, TzTime (http://github.com/rails/tztime/tree/master) is now supported.

This commit is contained in:
Zack Chandler
2008-09-05 11:16:24 -07:00
parent 7acdac2a1c
commit 24bf446b0e

View File

@@ -126,16 +126,13 @@ module Liquid
return input.to_s
end
date = case input
when String
Time.parse(input)
when Date, Time, DateTime
input
date = input.is_a?(String) ? Time.parse(input) : input
if date.respond_to?(:strftime)
date.strftime(format.to_s)
else
return input
input
end
date.strftime(format.to_s)
rescue => e
input
end