Sha256: 7114b4c15f9b3af64261ff858fb6b779f5dc3b443e3768a0966d06a72955ac03

Contents?: true

Size: 671 Bytes

Versions: 12

Compression:

Stored size: 671 Bytes

Contents

module Alchemy
  module Ingredients
    class DatetimeView < BaseView
      attr_reader :date_format

      # @param ingredient [Alchemy::Ingredient]
      # @param date_format [String] The date format to use. Use either a strftime format string, a I18n format symbol or "rfc822".
      def initialize(ingredient, date_format: nil, html_options: {})
        super(ingredient)
        @date_format = settings_value(:date_format, value: date_format)
      end

      def call
        if date_format == "rfc822"
          ingredient.value.to_s(:rfc822)
        else
          ::I18n.l(ingredient.value, format: date_format)
        end.html_safe
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-7.2.4 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.1.11 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.2.3 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.1.10 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.2.2 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.1.9 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.0.14 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.2.1 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.0.13 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.1.8 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.1.7 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.0.12 app/components/alchemy/ingredients/datetime_view.rb