Sha256: cf79c011440f2752d46275db13364949c3334844d0115564af1afa0e2fad73df
Contents?: true
Size: 977 Bytes
Versions: 42
Compression:
Stored size: 977 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"] = datetime_value(options["value"] || value) options["min"] = format_datetime(parse_datetime(options["min"])) options["max"] = format_datetime(parse_datetime(options["max"])) @options = options super end private def datetime_value(value) if value.is_a?(String) value else format_datetime(value) end end def format_datetime(value) raise NotImplementedError end def parse_datetime(value) if value.is_a?(String) DateTime.parse(value) rescue nil else value end end end end end end
Version data entries
42 entries across 42 versions & 6 rubygems