Sha256: 474e0835924a9ebe6e26e7cd502ae8be2a3f3099ebeffcfac884a7dabd3299b4

Contents?: true

Size: 800 Bytes

Versions: 10

Compression:

Stored size: 800 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". Defaults to "time.formats.alchemy.default".
      def initialize(ingredient, date_format: :"alchemy.default", html_options: {})
        super(ingredient)
        @date_format = settings_value(:date_format, value: date_format)
      end

      def call
        datetime = ingredient.value.in_time_zone(Rails.application.config.time_zone)
        if date_format == "rfc822"
          datetime.to_fs(:rfc822)
        else
          ::I18n.l(datetime, format: date_format)
        end.html_safe
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.6 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.4.1 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.4.0 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.5 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.4 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.3 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.2 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.1 app/components/alchemy/ingredients/datetime_view.rb
alchemy_cms-7.3.0 app/components/alchemy/ingredients/datetime_view.rb