DateHelper
The DateHelper class contains two kinds of helper methods. There’s a
small set of methods for expressing times in somewhat more
human-friendly forms:
distance_of_time_in_wordsTakes two time values and expresses how far apart they are in rough word descriptions rather than precise time notation—e.g., “2 days,” or “about 1 month,” or “less than a minute.”
distance_of_time_in_words_to_nowortime_ago_in_wordsLike
distance_of_time_in_words, but with theto_timealways set tonow.
Most of DateHelper’s methods,
though, create form fields for specifying times and dates. They’re kind
of clunky, but they may be useful for when you’re getting started or
when you feel like overriding them. Three of them are bound to
particular objects of type :date,
:time, or type :datetime:
date_selectThe
date_selectmethod creates drop-down year, month, and day select fields bound to a particular ActiveRecord object of type:date.datetime_selectThe
datetime_selectmethod creates drop-down year, month, day, hour, minute, and second select fields bound to a particular ActiveRecord object of type:datetime.time_selectThe
time_selectmethod creates drop-down hour, minute, and second select fields bound to a particular ActiveRecord object of type:time.
The rest of DateHelper’s
methods create HTML form fields, but aren’t bound to any particular
ActiveRecord object:
select_dateThe
select_datemethod creates drop-down year, month, and day select fields.select_datetimeThe
select_datetimemethod creates drop-down ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access