Module: Elabs::TimeHelper
- Defined in:
- app/helpers/elabs/time_helper.rb
Instance Method Summary collapse
- #date_time_to_date(time) ⇒ Object
- #date_time_to_time(time) ⇒ Object
- #same_day?(previous_date_time, current_date_time) ⇒ Boolean
- #short_date(date) ⇒ Object
Instance Method Details
#date_time_to_date(time) ⇒ Object
12 13 14 |
# File 'app/helpers/elabs/time_helper.rb', line 12 def date_time_to_date(time) time.strftime(_('%Y-%m-%d')) end |
#date_time_to_time(time) ⇒ Object
16 17 18 |
# File 'app/helpers/elabs/time_helper.rb', line 16 def date_time_to_time(time) time.strftime(_('%I:%M %p')) end |
#same_day?(previous_date_time, current_date_time) ⇒ Boolean
3 4 5 6 7 8 9 10 |
# File 'app/helpers/elabs/time_helper.rb', line 3 def same_day?(previous_date_time, current_date_time) return false if previous_date_time.nil? date1 = Date.parse(previous_date_time.to_s) date2 = Date.parse(current_date_time.to_s) date1 == date2 end |
#short_date(date) ⇒ Object
20 21 22 23 24 |
# File 'app/helpers/elabs/time_helper.rb', line 20 def short_date(date) return nil if date.nil? I18n.l date, format: :short end |