Sha256: e6fa914920ec4f3b1187b0df4c65d0788d7f50c6134b86cb66ed3aa208010c43

Contents?: true

Size: 491 Bytes

Versions: 37

Compression:

Stored size: 491 Bytes

Contents

# frozen_string_literal: true

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

      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

37 entries across 37 versions & 1 rubygems

Version Path
alchemy_cms-7.2.4 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.11 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.3 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.10 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.2 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.9 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.14 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.2.1 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.13 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.8 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.7 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.12 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.11 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.6 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.5 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.10 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.4 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.0.9 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.3 app/models/alchemy/ingredients/datetime.rb
alchemy_cms-7.1.2 app/models/alchemy/ingredients/datetime.rb