Sha256: 42a69cf479a0bcd056584231bc21d5d5c40da352e559bd565d9e4d5d0200a4a3

Contents?: true

Size: 376 Bytes

Versions: 4

Compression:

Stored size: 376 Bytes

Contents

# frozen_string_literal: true

require 'motoko/utils/time_ago'

require 'date'

module Motoko
  module Formatters
    class TimestampAgo < BaseFormatter
      include Motoko::Utils::TimeAgo

      def format(value)
        return nil unless value

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
motoko-1.2.1 lib/motoko/formatters/timestamp_ago.rb
motoko-1.2.0 lib/motoko/formatters/timestamp_ago.rb
motoko-1.1.0 lib/motoko/formatters/timestamp_ago.rb
motoko-1.0.0 lib/motoko/formatters/timestamp_ago.rb