Sha256: 229e798501b731189f87461053f35fe0041c082099a3f04cadb8fbbeef57ab9a

Contents?: true

Size: 860 Bytes

Versions: 5

Compression:

Stored size: 860 Bytes

Contents

module Jekyll
  module Filters
    module LanguageDate
      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 = JekyllLanguagePlugin::LiquidContext.get_language_string(@context, fkey)
        return "" if format.nil?

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

Liquid::Template.register_filter(Jekyll::Filters::LanguageDate)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.1.4 lib/jekyll/filters/language_date.rb
jekyll-language-plugin-1.1.3 lib/jekyll/filters/language_date.rb
jekyll-language-plugin-1.1.2 lib/jekyll/filters/language_date.rb
jekyll-language-plugin-1.1.1 lib/jekyll/filters/language_date.rb
jekyll-language-plugin-1.1.0 lib/jekyll/filters/language_date.rb