Class: Motoko::Formatters::DatetimeAgo

Inherits:
BaseFormatter show all
Includes:
Utils::TimeAgo
Defined in:
lib/motoko/formatters/datetime_ago.rb

Instance Method Summary collapse

Methods included from Utils::TimeAgo

#seconds_to_human

Methods inherited from BaseFormatter

#initialize

Constructor Details

This class inherits a constructor from Motoko::Formatters::BaseFormatter

Instance Method Details

#format(value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/motoko/formatters/datetime_ago.rb', line 12

def format(value)
  return nil unless value

  seconds_to_human(Time.now - DateTime.parse(value).to_time)
rescue ArgumentError
  nil
end