Completed helper function for time conversion, too sleepy to go on