Module: Bridgetown::Filters::DateFilters
- Included in:
- Bridgetown::Filters
- Defined in:
- bridgetown-core/lib/bridgetown-core/filters/date_filters.rb
Instance Method Summary collapse
-
#date_to_long_string(date, type = nil, style = nil) ⇒ String
Format a date in long format e.g.
-
#date_to_rfc822(date) ⇒ String
Format a date according to RFC-822, e.g.
-
#date_to_string(date, type = nil, style = nil) ⇒ String
Format a date in short format e.g.
-
#date_to_xmlschema(date) ⇒ String
Format a date for use in XML, e.g.
Instance Method Details
#date_to_long_string(date, type = nil, style = nil) ⇒ String
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.
30 31 32 |
# File 'bridgetown-core/lib/bridgetown-core/filters/date_filters.rb', line 30 def date_to_long_string(date, type = nil, style = nil) stringify_date(date, "%B", type, style) end |
#date_to_rfc822(date) ⇒ String
Format a date according to RFC-822, e.g. “Sun, 24 Apr 2011 12:34:46 +0000”
48 49 50 51 52 |
# File 'bridgetown-core/lib/bridgetown-core/filters/date_filters.rb', line 48 def date_to_rfc822(date) return date if date.to_s.empty? time(date).rfc822 end |
#date_to_string(date, type = nil, style = nil) ⇒ String
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.
16 17 18 |
# File 'bridgetown-core/lib/bridgetown-core/filters/date_filters.rb', line 16 def date_to_string(date, type = nil, style = nil) stringify_date(date, "%b", type, style) end |
#date_to_xmlschema(date) ⇒ String
Format a date for use in XML, e.g. “2011-04-24T20:34:46+08:00”
38 39 40 41 42 |
# File 'bridgetown-core/lib/bridgetown-core/filters/date_filters.rb', line 38 def date_to_xmlschema(date) return date if date.to_s.empty? time(date).xmlschema end |