Class: Effective::TableRows::DatetimeField
- Inherits:
-
Effective::TableRow
- Object
- Effective::TableRow
- Effective::TableRows::DatetimeField
- Defined in:
- app/models/effective/table_rows/datetime_field.rb
Instance Attribute Summary
Attributes inherited from Effective::TableRow
#builder, #name, #options, #template
Instance Method Summary collapse
Methods inherited from Effective::TableRow
#controller_namespace, #hint, #initialize, #label, #label_content, #to_html, #tr_class, #value
Constructor Details
This class inherits a constructor from Effective::TableRow
Instance Method Details
#content ⇒ Object
7 8 9 |
# File 'app/models/effective/table_rows/datetime_field.rb', line 7 def content nice_date_time(value) end |
#nice_date_time(value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/effective/table_rows/datetime_field.rb', line 11 def nice_date_time(value) return unless value.respond_to?(:strftime) label = value.strftime("%b %-d, %Y %l:%M%P") full = value.strftime("%A %b %-d, %Y %l:%M%P %z") now = Time.zone.now distance = if (now > value) template.distance_of_time_in_words(now, value) + ' ago' else template.distance_of_time_in_words(value, now) + ' from now' end content_tag(:span, label, title: full + ' (' + distance + ')') end |