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
- VERSION =
'0.1.0'
Instance Method Summary collapse
Instance Method Details
#time_compact(time, now = Time.now) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/time_compact.rb', line 6 def time_compact(time, now = Time.now) locale_dir = File.('../../locale', __FILE__) ::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 ::I18n.t( 'time_compact.same_hour', year: time.year, month: time.month, day: time.day, hour: time.hour, min: time.min ) else ::I18n.t( 'time_compact.same_day', year: time.year, month: time.month, day: time.day, hour: time.hour, min: '%02d' % time.min ) end else ::I18n.t( 'time_compact.same_month', year: time.year, month: time.month, day: time.day, hour: time.hour, min: '%02d' % time.min ) end else ::I18n.t( 'time_compact.same_year', year: time.year, month: time.month, day: time.day, hour: time.hour, min: '%02d' % time.min ) end else ::I18n.t( 'time_compact.other', year: time.year, month: time.month, day: time.day, hour: time.hour, min: '%02d' % time.min ) end end |