Skip to content

Commit b28a1eb

Browse files
Fix: Fixed validate_dates() function after datetime related unittests failed.
1 parent 2ce14da commit b28a1eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Travel_Itinerary_Planner/src/manage_itineraries.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,27 @@ def validate_dates(start_date, end_date, flights):
284284
"""
285285

286286
try:
287-
datetime.strptime(start_date, "%d-%m-%Y")
287+
datetime.strptime(start_date, "dd-mm-YYYY")
288288
except ValueError:
289289
print("Error: Invalid start date. Use 'DD-MM-YYYY' format.")
290290
return False
291291

292292
try:
293-
datetime.strptime(end_date, "%d-%m-%Y")
293+
datetime.strptime(end_date, "dd-mm-YYYY")
294294
except ValueError:
295295
print("Error: Invalid end date. Use 'DD-MM-YYYY' format.")
296296
return False
297297

298298
# Resource used for following code: https://stackoverflow.com/questions/17322208/multiple-try-codes-in-one-block
299299
for flight_info in flights:
300300
try:
301-
datetime.strptime(flight_info["departure date"], "%d-%m-%Y %H:%M")
301+
datetime.strptime(flight_info["departure date"], "dd-mm-YYYY HH:MM")
302302
except ValueError:
303303
print("Error: Invalid date/time for flight departure. Use 'DD-MM-YYYY HH:MM' format.")
304304
return False
305305

306306
try:
307-
datetime.strptime(flight_info["arrival date"], "%d-%m-%Y %H:%M")
307+
datetime.strptime(flight_info["arrival date"], "dd-mm-YYYY HH:MM")
308308
except ValueError:
309309
print("Error: Invalid date/time for flight arrival. Use 'DD-MM-YYYY HH:MM' format.")
310310
return False

0 commit comments

Comments
 (0)