module Trenni::Formatters::RelativeTime

Public Class Methods

included(base) click to toggle source
# File lib/trenni/formatters/relative_time.rb, line 29
def self.included(base)
        base.map(Time) do |object, **options|
                current_time = options.fetch(:current_time) {Time.now}
                
                # Ensure we display the time in localtime, and show the year if it is different:
                if object.localtime.year != current_time.year
                        object.localtime.strftime("%B %-d, %-l:%M%P, %Y")
                else
                        object.localtime.strftime("%B %-d, %-l:%M%P")
                end
        end
end