Courtesy of the clever helper method from this link: http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails https://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
def time_to_alarm_in_words time
#AN EMPTY STRING WE WILL BE ADDING TO
time_in_words = ''
#THE TIME TO THE ALARM IN SECONDS
total_seconds = (time - Time.now).to_i
time_in_words = humanize total_seconds
#RETURN THE RESULT
return time_in_words + " in the future"
end
Courtesy of the clever helper method from this link: http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
def time_to_alarm_in_words time
#AN EMPTY STRING WE WILL BE ADDING TO
time_in_words = ''
#THE TIME TO THE ALARM IN SECONDS
total_seconds = (time - Time.now).to_i
time_in_words = humanize total_seconds
#RETURN THE RESULT
return time_in_words + " in the future"
end
Courtesy of the clever helper method from this link: https://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
def time_to_alarm_in_words time
#AN EMPTY STRING WE WILL BE ADDING TO
time_in_words = ''
#THE TIME TO THE ALARM IN SECONDS
total_seconds = (time - Time.now).to_i
time_in_words = humanize total_seconds
#RETURN THE RESULT
return time_in_words + " in the future"
end
Courtesy of the clever helper method from this link: http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
def time_to_alarm_in_words time
#AN EMPTY STRING WE WILL BE ADDING TO
time_in_words = ''
#THE TIME TO THE ALARM IN SECONDS
total_seconds = (time - Time.now).to_i
time_in_words = humanize total_seconds
#RETURN THE RESULT
return time_in_words + " in the future"
end