app/helpers/timepiece_helper.rb in timepiece-0.3.0 vs app/helpers/timepiece_helper.rb in timepiece-0.4.0
- old
+ new
@@ -66,56 +66,53 @@
end
def timer(time_since = Time.now, id: '')
seconds_diff = (Time.now - time_since).to_i
- days = seconds_diff / 86400
- seconds_diff -= days * 86400
-
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
minutes = seconds_diff / 60
seconds_diff -= minutes * 60
seconds = seconds_diff
- time = "<span class='timepiece-days'>#{days.to_s}</span>"\
- "<span class='timepiece-separator tp-separator-days-hours'>:</span>"\
- "<span class='timepiece-hours'>#{"%02d" % hours}</span>"\
+ time = "<span class='timepiece-hours'>#{"%02d" % hours}</span>"\
"<span class='timepiece-separator tp-separator-hours-minutes'>:</span>"\
"<span class='timepiece-minutes'>#{"%02d" % minutes}</span>"\
"<span class='timepiece-separator tp-separator-minutes-seconds'>:</span>"\
"<span class='timepiece-seconds'>#{"%02d" % seconds}</span>"
# "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
- content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
+ content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
end
- def timer_in_words(time_since = Time.now, id: '')
- seconds_diff = (Time.now - time_since).to_i
+ if false
+ def timer_in_words(time_since = Time.now, id: '')
+ seconds_diff = (Time.now - time_since).to_i
- days = seconds_diff / 86400
- seconds_diff -= days * 86400
+ days = seconds_diff / 86400
+ seconds_diff -= days * 86400
- hours = seconds_diff / 3600
- seconds_diff -= hours * 3600
+ hours = seconds_diff / 3600
+ seconds_diff -= hours * 3600
- minutes = seconds_diff / 60
- seconds_diff -= minutes * 60
+ minutes = seconds_diff / 60
+ seconds_diff -= minutes * 60
- seconds = seconds_diff
+ seconds = seconds_diff
- time = "<span class='timepiece-days'>#{days.to_s}</span>"\
- "<span class='timepiece-descriptor tp-descriptor-days'> days </span>"\
- "<span class='timepiece-hours'>#{hours.to_s}</span>"\
- "<span class='timepiece-descriptor tp-descriptor-hours'> hours </span>"\
- "<span class='timepiece-minutes'>#{minutes.to_s}</span>"\
- "<span class='timepiece-descriptor tp-descriptor-minutes'> minutes </span>"\
- "<span class='timepiece-seconds'>#{seconds.to_s}</span>"\
- "<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
- # "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
+ time = "<span class='timepiece-days'>#{days.to_s}</span>"\
+ "<span class='timepiece-descriptor tp-descriptor-days'> days </span>"\
+ "<span class='timepiece-hours'>#{hours.to_s}</span>"\
+ "<span class='timepiece-descriptor tp-descriptor-hours'> hours </span>"\
+ "<span class='timepiece-minutes'>#{minutes.to_s}</span>"\
+ "<span class='timepiece-descriptor tp-descriptor-minutes'> minutes </span>"\
+ "<span class='timepiece-seconds'>#{seconds.to_s}</span>"\
+ "<span class='timepiece-descriptor tp-descriptor-seconds'> seconds </span>"
+ # "<span class='timepiece-seconds'>#{seconds.to_s.rjust(2, '0')}</span>" # Note: rjust; it might be useful.
- content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
+ content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => (id unless id.blank?))
+ end
end
def countdown(time_until = Time.new(2016), id: '')
seconds_diff = (time_until - Time.now).to_i
\ No newline at end of file