Module: HumanDate::ViewHelpers

Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/human_date/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#human_date(object, namespace = nil) ⇒ Object Also known as: human_time



5
6
7
# File 'lib/human_date/view_helpers.rb', line 5

def human_date(object, namespace = nil)
  I18n.localize(object, format: format_for_object(object, namespace)).strip
end

#human_time_tag(object, namespace_or_options = nil, options = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/human_date/view_helpers.rb', line 10

def human_time_tag(object, namespace_or_options = nil, options = nil)
  if namespace_or_options.is_a? Hash
    namespace = nil
    options = namespace_or_options
  else
    namespace = namespace_or_options
    options ||= {}
  end

  options.merge! datetime: object.iso8601

   :time, human_time(object, namespace), options
end