Module: Parliament::Grom::Decorator::Helpers::DateHelper
- Included in:
- ConstituencyGroup, FormalBodyMembership, Parliament::Grom::Decorator::HouseIncumbency, Incumbency, ParliamentPeriod, PartyMembership, Person, SeatIncumbency
- Defined in:
- lib/parliament/grom/decorator/helpers/date_helper.rb
Overview
Namespace for date helper methods
Instance Method Summary collapse
-
#date_range(date_format: '%-e %b %Y') ⇒ Object
Format start_date and end_date into a readable string.
Instance Method Details
#date_range(date_format: '%-e %b %Y') ⇒ Object
Format start_date and end_date into a readable string
11 12 13 14 15 16 17 18 |
# File 'lib/parliament/grom/decorator/helpers/date_helper.rb', line 11 def date_range(date_format: '%-e %b %Y') return '[Date unavailable]' if start_date.nil? if end_date "#{I18n.l(start_date, format: date_format)} #{I18n.t('to')} #{I18n.l(end_date, format: date_format)}" else "#{I18n.l(start_date, format: date_format)} #{I18n.t('to_present')}" end end |