Sha256: 9d469a1e42a4a1b546dbca3b5c500b2c341523ec31b0f30956240296730f9957

Contents?: true

Size: 745 Bytes

Versions: 47

Compression:

Stored size: 745 Bytes

Contents

module ActionView
  module Helpers
    module Tags # :nodoc:
      class DatetimeField < TextField # :nodoc:
        def render
          options = @options.stringify_keys
          options["value"] ||= format_date(value(object))
          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

47 entries across 47 versions & 4 rubygems

Version Path
actionview-5.1.7 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.7.rc1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.6.2 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.7.2 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.6.1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.7.1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.6 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.7 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.5 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.5.rc1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.4 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.6 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.4.rc1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.6.rc1 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.3 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.3.rc3 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.5 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.5.rc2 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.1.3.rc2 lib/action_view/helpers/tags/datetime_field.rb
actionview-5.0.5.rc1 lib/action_view/helpers/tags/datetime_field.rb