Sha256: dcb15380514b2cbdb0adc32de2725e8a6fd0a880a7c27fdf532d6ef3afc33ffc

Contents?: true

Size: 569 Bytes

Versions: 4

Compression:

Stored size: 569 Bytes

Contents

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

        private

          def format_date(value)
            value.try(:strftime, "%Y-%m-%dT%T.%L%z")
          end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
challah-1.0.0 vendor/bundle/gems/actionpack-4.0.0/lib/action_view/helpers/tags/datetime_field.rb
actionpack-4.0.0 lib/action_view/helpers/tags/datetime_field.rb
actionpack-4.0.0.rc2 lib/action_view/helpers/tags/datetime_field.rb
actionpack-4.0.0.rc1 lib/action_view/helpers/tags/datetime_field.rb