converts time correctly