Merge pull request #892 from rafaelrosafu/master
Added date_to_rfc822 used on RSS feeds
This commit is contained in:
commit
7b36d26240
|
@ -56,6 +56,20 @@ module Jekyll
|
|||
date.xmlschema
|
||||
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
|
||||
# appropriate HTML entity replacements.
|
||||
#
|
||||
|
|
|
@ -13,6 +13,7 @@ class TestFilters < Test::Unit::TestCase
|
|||
context "filters" do
|
||||
setup do
|
||||
@filter = JekyllFilter.new
|
||||
@sample_time = Time.utc(2013, 03, 27, 11, 22, 33)
|
||||
end
|
||||
|
||||
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"])
|
||||
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:33Z", @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
|
||||
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
||||
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
||||
|
|
Loading…
Reference in New Issue