Sha256: f834c40d7ae05cc011531cc140cd09a795eff2595cd4690a7731c89b0457221b

Contents?: true

Size: 832 Bytes

Versions: 11

Compression:

Stored size: 832 Bytes

Contents

module Locomotive
  module Liquid
    module Filters
      module Date

        def localized_date(input, *args)
          return '' if input.blank?

          format, locale = args

          locale ||= I18n.locale
          format ||= I18n.t('date.formats.default', :locale => locale)

          if input.is_a?(String)
            begin
              fragments = ::Date._strptime(input, format)
              input = ::Date.new(fragments[:year], fragments[:mon], fragments[:mday])
            rescue
              input = Time.parse(input)
            end
          end

          return input.to_s unless input.respond_to?(:strftime)

          I18n.l input, :format => format, :locale => locale
        end

        alias :format_date :localized_date

      end

      ::Liquid::Template.register_filter(Date)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc12 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc11 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc10 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc7 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc6 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc5 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc4 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc2 lib/locomotive/liquid/filters/date.rb
locomotive_cms-2.0.0.rc1 lib/locomotive/liquid/filters/date.rb