Module: TimeCompact
- Defined in:
- lib/time_compact.rb,
lib/time_compact/railtie.rb,
lib/time_compact/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- LOCALE_DIR =
File.('../../locale', __FILE__)
- VERSION =
'0.2.0'
Instance Method Summary collapse
Instance Method Details
#time_compact(time, now = Time.now) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/time_compact.rb', line 9 def time_compact(time, now = Time.now) I18n.enforce_available_locales = true I18n.load_path += Dir[LOCALE_DIR + '/*.yml'] if time.year == now.year if time.month == now.month if time.day == now.day if time.hour == now.hour time.strftime(fetch_locale('same_hour')) else time.strftime(fetch_locale('same_day')) end else time.strftime(fetch_locale('same_month')) end else time.strftime(fetch_locale('same_year')) end else time.strftime(fetch_locale('other')) end end |