mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user