Quiz App Logo
Python timezones

Now, instead of going to bed and setting an alarm, let's consider a person who boards a bus in Berlin on Saturday at 9:00 PM (CEST) and arrives in Paris on Sunday at 9:00 AM (CET).

Both Germany and France share the same UTC offset and follow identical daylight saving time rules.

from zoneinfo import ZoneInfo
from datetime import datetime

berlin = ZoneInfo("Europe/Berlin")
sat = datetime(2024, 10, 26, 21, 0, tzinfo=berlin)

paris = ZoneInfo("Europe/Paris")
sun = datetime(2024, 10, 27, 9, 0, tzinfo=paris)

assert sat.isoformat() == '2024-10-26T21:00:00+02:00'
assert sun.isoformat() == '2024-10-27T09:00:00+01:00'

diff = sun - sat

How long is the timedelta diff?

11 hours
12 hours
13 hours