datetime – Python EU travel visa calculator

Interesting start to what seems a very useful utility. Future improvements could improve console calendar-style formatting for much easier reading, or a desktop or web UI.

Your YYYY,MM,DD format is unusual. A slight adjustment to use hyphens instead of commas will bring it in line with ISO 8601 which will be more familiar, I think, to users. Or if you don’t want to use that, you should use your locale’s own date format, whatever that may be.

You should separate your Enter trip start and end date into two separate input calls.

Don’t do this:

visa_start_input_split = visa_start_input.split(",")
visa_start = date(int(visa_start_input_split(0)), int(visa_start_input_split(1)), int(visa_start_input_split(2)))

Instead, use date.fromisoformat or datetime.strptime(...).date().

timedelta(days=365) is not accurate, and unfortunately there’s no easy built-in way to do this right. relativedelta(years=1) from dateutil will do the trick.

I haven’t taken the time to understand your algorithm, but mutating your trip data here:

trip(0) += timedelta(days=1)

is not a good idea, and you should find some other way that preserves the trip data as immutable. If you’re able to make it immutable, then this:

for trip in planned_trips:

should become

for trip_start, trip_end in planned_trips: