# Test cases (outputs in seconds)
timeFormater("4-12") # day-hours
timeFormater("4-12:15") # day-hours:minutes
timeFormater("4-12:15:30") # day-hours:minutes:seconds
timeFormater("30") # minutes
timeFormater("30:30") # minutes:seconds
timeFormater("4:30:30") # hours:minutes:seconds
# output in hours
timeFormater("4-12", output = 'hour')
timeFormater("4-12:15", output = 'hour')
timeFormater("4-12:15:30", output = 'hour')
timeFormater("30", output = 'hour')
timeFormater("30:30", output = 'hour')
timeFormater("4:30:30", output = 'hour')
Run the code above in your browser using DataLab