Module: FormatTime
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- lib/format_time.rb,
lib/format_time/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Method Summary collapse
- #format_absolute_time(time) ⇒ Object
-
#format_relative_time(time) ⇒ Object
Your code goes here…
Instance Method Details
#format_absolute_time(time) ⇒ Object
15 16 17 18 19 |
# File 'lib/format_time.rb', line 15 def format_absolute_time(time) return '-' if time.nil? Time.current.year == time.year ? in_year(time) : previous_year(time) end |
#format_relative_time(time) ⇒ Object
Your code goes here…
9 10 11 12 13 |
# File 'lib/format_time.rb', line 9 def format_relative_time(time) return '-' if time.nil? distance_of_time_in_words_to_now(time, include_seconds: true) end |