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_words
Takes 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_now
ortime_ago_in_words
Like
distance_of_time_in_words
, but with theto_time
always 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_select
The
date_select
method creates drop-down year, month, and day select fields bound to a particular ActiveRecord object of type:date
.datetime_select
The
datetime_select
method creates drop-down year, month, day, hour, minute, and second select fields bound to a particular ActiveRecord object of type:datetime
.time_select
The
time_select
method 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_date
The
select_date
method creates drop-down year, month, and day select fields.select_datetime
The
select_datetime ...
Get Learning Rails now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.