Sha256: f09337c640acf10061dd20d787aa404e74d54f6eaef48bcaddd1766bf5bf2cbf

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

module Jekyll
  module LanguagePlugin
    module Filters
      module LanguageDateFilter
        def tdate(input, fkey)
          if ((input.is_a?(String) && !/^\d+$/.match(input).nil?) || input.is_a?(Integer)) && input.to_i > 0
            date = Time.at(input.to_i)
          elsif input.is_a?(String)
            case input.downcase
            when 'now', 'today'
              date = Time.now
            else
              date = Time.parse(input)
            end
          elsif input.is_a?(Time)
            date = input
          else
            date = nil
          end

          return "" if !date.is_a?(Time)
          format = LiquidContext.get_language_string(@context, fkey)
          return "" if format.nil?

          Jekyll::LanguagePlugin::DateLocalizer.localize_date(date, format, @context).to_s
        end
      end
    end
  end
end

Liquid::Template.register_filter(Jekyll::LanguagePlugin::Filters::LanguageDateFilter)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.2.2 lib/jekyll/language-plugin/filters/language_date.rb
jekyll-language-plugin-1.2.0 lib/jekyll/language-plugin/filters/language_date.rb
jekyll-language-plugin-1.1.8 lib/jekyll/language-plugin/filters/language_date.rb
jekyll-language-plugin-1.1.7 lib/jekyll/language-plugin/filters/language_date.rb