Merge pull request #2377 from jekyll/numeric
This commit is contained in:
commit
04b0fe0160
|
@ -234,7 +234,7 @@ module Jekyll
|
||||||
input
|
input
|
||||||
when String
|
when String
|
||||||
Time.parse(input) rescue Time.at(input.to_i)
|
Time.parse(input) rescue Time.at(input.to_i)
|
||||||
when Number
|
when Numeric
|
||||||
Time.at(input)
|
Time.at(input)
|
||||||
else
|
else
|
||||||
Jekyll.logger.error "Invalid Date:", "'#{input}' is not a valid datetime."
|
Jekyll.logger.error "Invalid Date:", "'#{input}' is not a valid datetime."
|
||||||
|
|
|
@ -15,9 +15,10 @@ class TestFilters < Test::Unit::TestCase
|
||||||
|
|
||||||
context "filters" do
|
context "filters" do
|
||||||
setup do
|
setup do
|
||||||
@filter = JekyllFilter.new({"source" => source_dir, "destination" => dest_dir})
|
@filter = JekyllFilter.new({"source" => source_dir, "destination" => dest_dir, "timezone" => "UTC"})
|
||||||
@sample_time = Time.utc(2013, 03, 27, 11, 22, 33)
|
@sample_time = Time.utc(2013, 03, 27, 11, 22, 33)
|
||||||
@time_as_string = "September 11, 2001 12:46:30 -0000"
|
@time_as_string = "September 11, 2001 12:46:30 -0000"
|
||||||
|
@time_as_numeric = 1399680607
|
||||||
@array_of_objects = [
|
@array_of_objects = [
|
||||||
{ "color" => "red", "size" => "large" },
|
{ "color" => "red", "size" => "large" },
|
||||||
{ "color" => "red", "size" => "medium" },
|
{ "color" => "red", "size" => "medium" },
|
||||||
|
@ -88,6 +89,24 @@ class TestFilters < Test::Unit::TestCase
|
||||||
assert_equal "Tue, 11 Sep 2001 12:46:30 -0000", @filter.date_to_rfc822(@time_as_string)
|
assert_equal "Tue, 11 Sep 2001 12:46:30 -0000", @filter.date_to_rfc822(@time_as_string)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a Numeric object" do
|
||||||
|
should "format a date with short format" do
|
||||||
|
assert_equal "10 May 2014", @filter.date_to_string(@time_as_numeric)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a date with long format" do
|
||||||
|
assert_equal "10 May 2014", @filter.date_to_long_string(@time_as_numeric)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a time with xmlschema" do
|
||||||
|
assert_match /2014-05-10T00:10:07/, @filter.date_to_xmlschema(@time_as_numeric)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a time according to RFC-822" do
|
||||||
|
assert_equal "Sat, 10 May 2014 00:10:07 +0000", @filter.date_to_rfc822(@time_as_numeric)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "escape xml with ampersands" do
|
should "escape xml with ampersands" do
|
||||||
|
|
Loading…
Reference in New Issue