blob: 803f67f7606b774173cfb665a56dd38be4928765 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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 NoImplementedError
end
def datetime_value(value)
if value.is_a? String
DateTime.parse(value) rescue nil
else
value
end
end
end
end
end
end
|