Added filter date_to_rfc822
According to the W3C RSS Feed Validator, feeds must format dates as described on RFC-822 to be valid. Refer to their site to get more info: http://feedvalidator.org/docs/error/InvalidRFC2822Date.html I also added a couple of missing unit tests to the other date filters
This commit is contained in:
parent
58f64e8269
commit
186b68adb0
|
@ -56,6 +56,20 @@ module Jekyll
|
||||||
date.xmlschema
|
date.xmlschema
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Format a date according to RFC-822
|
||||||
|
#
|
||||||
|
# date - The Time to format.
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# date_to_rfc822(Time.now)
|
||||||
|
# # => "Sun, 24 Apr 2011 12:34:46 +0000"
|
||||||
|
#
|
||||||
|
# Returns the formatted String.
|
||||||
|
def date_to_rfc822(date)
|
||||||
|
date.rfc822
|
||||||
|
end
|
||||||
|
|
||||||
# XML escape a string for use. Replaces any special characters with
|
# XML escape a string for use. Replaces any special characters with
|
||||||
# appropriate HTML entity replacements.
|
# appropriate HTML entity replacements.
|
||||||
#
|
#
|
||||||
|
|
|
@ -13,6 +13,7 @@ class TestFilters < Test::Unit::TestCase
|
||||||
context "filters" do
|
context "filters" do
|
||||||
setup do
|
setup do
|
||||||
@filter = JekyllFilter.new
|
@filter = JekyllFilter.new
|
||||||
|
@sample_time = Time.parse "2013-03-27T11:22:33+00:00"
|
||||||
end
|
end
|
||||||
|
|
||||||
should "textilize with simple string" do
|
should "textilize with simple string" do
|
||||||
|
@ -42,6 +43,22 @@ class TestFilters < Test::Unit::TestCase
|
||||||
assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
|
assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "format a date with short format" do
|
||||||
|
assert_equal "27 Mar 2013", @filter.date_to_string(@sample_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a date with long format" do
|
||||||
|
assert_equal "27 March 2013", @filter.date_to_long_string(@sample_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a time with xmlschema" do
|
||||||
|
assert_equal "2013-03-27T11:22:33+00:00", @filter.date_to_xmlschema(@sample_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "format a time according to RFC-822" do
|
||||||
|
assert_equal "Wed, 27 Mar 2013 11:22:33 +0000", @filter.date_to_rfc822(@sample_time)
|
||||||
|
end
|
||||||
|
|
||||||
should "escape xml with ampersands" do
|
should "escape xml with ampersands" do
|
||||||
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
||||||
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
||||||
|
|
Loading…
Reference in New Issue