Added a time conversion function and fixed a little bug