Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Time of your with two digit in minutes like 5 to 50
- time_val="13.50"
- #split by "."
- split_val=time_val.split('.')
- #get a hours
- hour_val=split_val[0]
- #get a minutes
- min_val= (100*60)/split_val[1].to_i
- if(min_val == 60)
- hour_val +=1
- min_val=0
- end
- #it's concat a hours and minutes then it's final result
- final_time= hour_val.to_s + ":" + min_val + ":00"
- sec = (13.5 * 3600).to_i
- min, sec = sec.divmod(60)
- hour, min = min.divmod(60)
- "%02d:%02d:%02d" % [hour, min, sec] # => "13:30:00"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement