Fix Hours
From this great post https://blog.engineyard.com/2015/five-ruby-methods-you-should-be-using
def convert_to_hours(minutes)
hours = 0
until (0..60).include? minutes
hours -= (60 <=> minutes)
minutes += 60 * (60 <=> minutes)
end
{
hours: hours,
minutes: minutes
}
end
Written by Dinesh Vasudevan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#