Base code for convert time