Module: Jekyll::Filters::DateLocal
- Defined in:
- lib/jekyll/filters/date_local.rb
Instance Method Summary collapse
-
#date_local(input, format) ⇒ String
Translates month and day names.
Instance Method Details
#date_local(input, format) ⇒ String
Translates month and day names. This requires certain values on your _data/LANG.yml
Example usage:
page.date | date_local: ‘%e de %B de %Y’ }
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jekyll/filters/date_local.rb', line 17 def date_local(input, format) require 'date' input = ::Jekyll::Utils.parse_date(input) unless input.respond_to? :mon # Return early if we don't need to translate return input.strftime(format) unless /%(|\^)[aAbBpP]/ =~ format input.strftime translate_localization_format(input, format) rescue ArgumentError, TypeError, ::Jekyll::Errors::InvalidDateError => e Jekyll.logger.warn "#{input} is not a valid date: #{e.}" input end |