app/helpers/timepiece_helper.rb in timepiece-0.1.10 vs app/helpers/timepiece_helper.rb in timepiece-0.1.11
- old
+ new
@@ -1,7 +1,7 @@
module TimepieceHelper
- def timepiece(location = 'UTC', type: '24', lead: 'none', abbr_sep: 'none')
+ def timepiece(location = 'UTC', type: '24', lead: 'none', abbr_sep: 'none', id: '')
Time.zone = location
hours = Time.now.in_time_zone.strftime('%H')
minutes = Time.now.in_time_zone.strftime('%M')
seconds = Time.now.in_time_zone.strftime('%S')
if type == '12'
@@ -27,21 +27,21 @@
if abbr_sep == '.'
var = var.gsub(/([apm])/, '\1.')
end
end
time = "<span class='timepiece-hours'>#{hours}</span>"\
- "<span class='timepiece-separator tp-separator-1'>:</span>"\
+ "<span class='timepiece-separator tp-separator-1 tp-hours-minutes'>:</span>"\
"<span class='timepiece-minutes'>#{minutes}</span>"\
- "<span class='timepiece-separator tp-separator-2'>:</span>"\
+ "<span class='timepiece-separator tp-separator-2 tp-minutes-seconds'>:</span>"\
"<span class='timepiece-seconds'>#{seconds}</span>"
if type == '12'
time = time + "<span class='timepiece-abbr timepiece-abbr-#{var}'>#{var}</span>"
end
- content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep)
+ content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type, 'data-lead' => lead, 'data-abbr_separator' => abbr_sep, 'id' => id)
end
- def timer(time_since = Time.now)
+ def timer(time_since = Time.now, id: '')
seconds_diff = (Time.now - time_since).to_i
days = seconds_diff / 86400
seconds_diff -= days * 86400
@@ -61,14 +61,14 @@
"<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)
+ content_tag(:span, time.html_safe, class: 'timepiece-timer', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
end
- def countdown(time_until = Time.new(2016))
+ def countdown(time_until = Time.new(2016), id: '')
seconds_diff = (time_until - Time.now).to_i
days = seconds_diff / 86400
seconds_diff -= days * 86400
@@ -88,8 +88,8 @@
"<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-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds)
+ content_tag(:span, time.html_safe, class: 'timepiece-countdown', 'data-days' => days, 'data-hours' => hours, 'data-minutes' => minutes, 'data-seconds' => seconds, 'id' => id)
end
end
\ No newline at end of file