Sha256: d40ab2a6c3d573b05e0887a6b19cb7adfb7b0554ddb5479632c05425166b4601
Contents?: true
Size: 779 Bytes
Versions: 16
Compression:
Stored size: 779 Bytes
Contents
# frozen_string_literal: true require "active_support/core_ext/date_time/calculations" require "active_support/concern" module Decidim # A concern to render friendlier dates module FriendlyDates extend ActiveSupport::Concern # Returns the creation date in a friendly relative format. def friendly_created_at current_datetime = Time.zone.now if created_at > current_datetime.beginning_of_day I18n.l(created_at, format: :time_of_day) elsif created_at > current_datetime.beginning_of_week I18n.l(created_at, format: :day_of_week) elsif created_at > current_datetime.beginning_of_year I18n.l(created_at, format: :day_of_month) else I18n.l(created_at, format: :day_of_year) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems