Module: Jekyll::DateFilters
- Defined in:
- lib/liquid/filters/jekyll.rb
Instance Method Summary collapse
-
#date_to_long_string(date, type = nil, style = nil) ⇒ Object
Format a date in long format e.g.
-
#date_to_rfc822(date) ⇒ Object
Format a date according to RFC-822.
-
#date_to_string(date, type = nil, style = nil) ⇒ Object
Format a date in short format e.g.
-
#date_to_xmlschema(date) ⇒ Object
Format a date for use in XML.
Instance Method Details
#date_to_long_string(date, type = nil, style = nil) ⇒ Object
Format a date in long format e.g. “27 January 2011”. Ordinal format is also supported, in both the UK (e.g. “27th January 2011”) and US (“e.g. January 27th, 2011”) formats. UK format is the default.
date - the Time to format. type - if “ordinal” the returned String will be in ordinal format style - if “US” the returned String will be in US format.
Otherwise it will be in UK format.
Returns the formatted String.
97 98 99 |
# File 'lib/liquid/filters/jekyll.rb', line 97 def date_to_long_string(date, type = nil, style = nil) stringify_date(date, "%B", type, style) end |
#date_to_rfc822(date) ⇒ Object
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.
126 127 128 129 |
# File 'lib/liquid/filters/jekyll.rb', line 126 def date_to_rfc822(date) return date if date.to_s.empty? time(date).rfc822 end |
#date_to_string(date, type = nil, style = nil) ⇒ Object
Format a date in short format e.g. “27 Jan 2011”. Ordinal format is also supported, in both the UK (e.g. “27th Jan 2011”) and US (“e.g. Jan 27th, 2011”) formats. UK format is the default.
date - the Time to format. type - if “ordinal” the returned String will be in ordinal format style - if “US” the returned String will be in US format.
Otherwise it will be in UK format.
Returns the formatting String.
82 83 84 |
# File 'lib/liquid/filters/jekyll.rb', line 82 def date_to_string(date, type = nil, style = nil) stringify_date(date, "%b", type, style) end |
#date_to_xmlschema(date) ⇒ Object
Format a date for use in XML.
date - The Time to format.
Examples
date_to_xmlschema(Time.now)
# => "2011-04-24T20:34:46+08:00"
Returns the formatted String.
111 112 113 114 |
# File 'lib/liquid/filters/jekyll.rb', line 111 def date_to_xmlschema(date) return date if date.to_s.empty? time(date).xmlschema end |