Date conversion function.