Class: Motoko::Formatters::TimestampAgo

Inherits:
BaseFormatter show all
Includes:
Utils::TimeAgo
Defined in:
lib/motoko/formatters/timestamp_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/timestamp_ago.rb', line 12

def format(value)
  return nil unless value

  seconds_to_human(Time.now - Time.at(Integer(value)))
rescue ArgumentError
  nil
end