Sha256: fcb2e3e0db5b61fb61a22274d8c9a558fff838299cf749ef25a19dedc8e87c75
Contents?: true
Size: 812 Bytes
Versions: 13
Compression:
Stored size: 812 Bytes
Contents
# frozen_string_literal: true module Decidim # Helper to format date ranges module DateRangeHelper def format_date_range(start_date, end_date) return if [start_date, end_date].any?(&:blank?) format = [start_date.year, end_date.year].any? { |year| year != Date.current.year } ? :decidim_short_with_month_name_short : :decidim_with_month_name_short if start_date.to_date == end_date.to_date && start_date.to_time == end_date.to_time l(start_date.to_date, format:) elsif start_date.to_date == end_date.to_date "#{l(start_date.to_date, format:)} #{l(start_date, format: :time_of_day)} → #{l(end_date, format: :time_of_day)}".html_safe else "#{l(start_date.to_date, format:)} → #{l(end_date.to_date, format:)}".html_safe end end end end
Version data entries
13 entries across 13 versions & 1 rubygems