Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/liquid/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Liquid
module Utils
DECIMAL_REGEX = /\A-?\d+\.\d+\z/
UNIX_TIMESTAMP_REGEX = /\A\d+\z/
UNIX_TIMESTAMP_REGEX = /\A-?\d+\z/

def self.slice_collection(collection, from, to)
if (from != 0 || !to.nil?) && collection.respond_to?(:load_slice)
Expand Down
9 changes: 9 additions & 0 deletions test/integration/standard_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,15 @@ def test_date
end
end

def test_date_with_negative_unix_timestamp_string
with_timezone("UTC") do
assert_equal("12/31/1969", @filters.date(-1, "%m/%d/%Y"))
assert_equal("12/31/1969", @filters.date("-1", "%m/%d/%Y"))
assert_equal("01/01/1900", @filters.date("-2208988800", "%m/%d/%Y"))
assert_template_result("12/31/1969", '{{ timestamp | date: "%m/%d/%Y" }}', { 'timestamp' => '-1' })
end
end

def test_first_last
assert_equal(1, @filters.first([1, 2, 3]))
assert_equal(3, @filters.last([1, 2, 3]))
Expand Down
Loading