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
+5 -8
View File
@@ -126,16 +126,13 @@ module Liquid
return input.to_s return input.to_s
end end
date = case input date = input.is_a?(String) ? Time.parse(input) : input
when String
Time.parse(input) if date.respond_to?(:strftime)
when Date, Time, DateTime date.strftime(format.to_s)
input
else else
return input input
end end
date.strftime(format.to_s)
rescue => e rescue => e
input input
end end