Sha256: 64a2c721350ccf5f656f424757c2a09b44f87d52e372b07370a4498c7da209e7

Contents?: true

Size: 502 Bytes

Versions: 10

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Ingredients
    # A datetime value
    #
    class Datetime < Alchemy::Ingredient
      allow_settings %i[date_format input_type]

      def value
        ActiveRecord::Type::DateTime.new.cast(self[:value])
      end

      # Returns localized date for the Element#preview_text method.
      def preview_text(_maxlength = nil)
        return "" unless value

        ::I18n.l(value, format: :"alchemy.ingredient_date")
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.3.3 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.3.2 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.7 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.3.1 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.3.0 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.6 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.5 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.12 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.15 app/models/alchemy/ingredients/datetime.rb