Skip to content
This repository
tree: 2a16e159ab
Fetching contributors…

Cannot retrieve contributors at this time

file 22 lines (20 sloc) 0.569 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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
Something went wrong with that request. Please try again.