Having to set 6 comboboxes just to enter a date/time is simply overkill
to me. I prefer a simple text field where I can (e.g. for date input
fields) input strings like
2007-12-02
+3 (remark: means the date of 3 days after today)
12-05 (remark: will be completed with the current year)
I already have implemented the functionality of parsing these dates,
but now I am not sure how to integrate it into the Rails framework
(plugin mechanism?).
Does anybody know how to do this? Is there some documentation about
writing own form helpers like this?
Having to set 6 comboboxes just to enter a date/time is simply overkill
to me. I prefer a simple text field where I can (e.g. for date input
fields) input strings like
2007-12-02
+3 (remark: means the date of 3 days after today)
12-05 (remark: will be completed with the current year)
I already have implemented the functionality of parsing these dates,
but now I am not sure how to integrate it into the Rails framework
(plugin mechanism?).
Does anybody know how to do this? Is there some documentation about
writing own form helpers like this?
>
I use this to display and parse european dates (dd.mm.yyyy).
module ActionView # :nodoc:
module Helpers # :nodoc:
class InstanceTag
def to_date_select_tag(options = {})
#to_input_field_tag('text', {'size'=>'10'}.merge(options))
options = options.stringify_keys
options["size"] ||= options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"]
options = DEFAULT_FIELD_OPTIONS.merge(options)
options["type"] = 'text'
options["value"] ||= value.to_formatted_s(options["date_format"] || :input_format) if value.kind_of?(Date)
add_default_name_and_id(options)
tag("input", options)
end
end
end
end
require ('parsedate')
module ParseDate
class << self
alias_method :old_parsedate, :parsedate unless method_defined?(:old_parsedate)
end
def self.parsedate(str)
match = /(\d{1,2})\.(\d{1,2})\.(\d{2,4})\.?/.match(str)
return ParseDate.old_parsedate(str) unless match
[match[3].to_i, match[2].to_i, match[1].to_i, nil, nil, nil, nil, nil]
end
end