Format sleep time and moved math logic to helper.