Sha256: 0ebe3b521620000ff06bf4b3690aca5dd8035c975b940ab896edf4027d635b85

Contents?: true

Size: 768 Bytes

Versions: 114

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module ActionView
  module Helpers
    module Tags # :nodoc:
      class DatetimeField < TextField # :nodoc:
        def render
          options = @options.stringify_keys
          options["value"] ||= format_date(value)
          options["min"] = format_date(datetime_value(options["min"]))
          options["max"] = format_date(datetime_value(options["max"]))
          @options = options
          super
        end

        private

          def format_date(value)
            raise NotImplementedError
          end

          def datetime_value(value)
            if value.is_a? String
              DateTime.parse(value) rescue nil
            else
              value
            end
          end
      end
    end
  end
end

Version data entries

114 entries across 106 versions & 7 rubygems

Version Path
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/actionview-6.0.0/lib/action_view/helpers/tags/datetime_field.rb
actionview-6.0.0 lib/action_view/helpers/tags/datetime_field.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
spiral_form-0.1.1 vendor/bundle/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
spiral_form-0.1.0 vendor/bundle/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
actionview-6.0.0.rc2 lib/action_view/helpers/tags/datetime_field.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/actionview-5.2.3/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.7 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.6 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.5 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.4 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.3 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.2 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.1 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.9.0 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.8.14 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb
jets-1.8.13 vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb