Class: JekyllLanguagePlugin::DateLocalizer::JLPTime

Inherits:
Time
  • Object
show all
Defined in:
lib/jekyll-language-plugin/date_localizer.rb

Instance Method Summary collapse

Instance Method Details

#strftime_translate(format = '%F', translation) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jekyll-language-plugin/date_localizer.rb', line 18

def strftime_translate(format = '%F', translation)
  result = self.strftime(
    #...you replaced the language dependent parts.
    format.gsub(/%([aAbB])/){ |m|
        case $1
          when 'a'; translation['abbr_daynames'][self.wday]
          when 'A'; translation['daynames'][self.wday]
          when 'b'; translation['abbr_monthnames'][self.mon-1]
          when 'B'; translation['monthnames'][self.mon-1]
          else
            raise JekyllLanguagePlugin::PluginError.new('Internal error.')
        end
      })
  if defined? @@encoding_converter
    @@encoding_converter.iconv(result)
  else
    result
  end
end