module Jekyll::Locale::DateTimeHandler

Constants

DATETIME_DEFAULTS

Public Class Methods

bootstrap(handler) click to toggle source
# File lib/jekyll/locale/date_time_handler.rb, line 27
def bootstrap(handler)
  @handler = handler
  config.available_locales = @handler.available_locales
end
localize(input, format) click to toggle source
# File lib/jekyll/locale/date_time_handler.rb, line 32
def localize(input, format)
  object = date_cache(input)
  locale = @handler.current_locale.id.to_sym
  data   = @handler.locale_dates[locale.to_s] || {}
  store_translations(locale, data) unless translations.key?(locale)
  backend.localize(locale, object, format)
end
store_translations(locale, data) click to toggle source
# File lib/jekyll/locale/date_time_handler.rb, line 40
def store_translations(locale, data)
  backend.store_translations(
    locale,
    Utils.deep_merge_hashes(
      DATETIME_DEFAULTS, Utils.recursive_symbolize_hash_keys(data)
    )
  )
end

Private Class Methods

date_cache(input) click to toggle source
# File lib/jekyll/locale/date_time_handler.rb, line 55
def date_cache(input)
  @date_cache ||= {}
  @date_cache[input] ||= Liquid::Utils.to_date(input)
end
translations() click to toggle source
# File lib/jekyll/locale/date_time_handler.rb, line 51
def translations
  backend.send(:translations)
end