Not sure if it works. 
My Idea was to to merge getTimeInHMS and formateInput and make the getTimeInHMS parse the branch in formateInput.