Added time conversion function