Refactored time_to_decimal for clarity.