Sha256: 20bfe354336822d72b41887b756072513a053332865f11bd5027c37fb1464190

Contents?: true

Size: 381 Bytes

Versions: 4

Compression:

Stored size: 381 Bytes

Contents

# frozen_string_literal: true

require 'motoko/utils/time_ago'

require 'date'

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

      def format(value)
        return nil unless value

        seconds_to_human(Time.now - DateTime.parse(value).to_time)
      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/datetime_ago.rb
motoko-1.2.0 lib/motoko/formatters/datetime_ago.rb
motoko-1.1.0 lib/motoko/formatters/datetime_ago.rb
motoko-1.0.0 lib/motoko/formatters/datetime_ago.rb