Deutsche Bahn is not known for its punctuality. Since the Euro 2024, it has been known for its delays. I’m a frequent train commuter and happended to ride on an ICE on September 2, 2024 that was scheduled to arrive at 7:47. When the train left my home station earlier that morning, it was delayed due to technical difficulties on the train. The actual arrival was 7:54. While disembarking the train, I took the following photo.

ICE screen showing delay of 2457017 min

Note, that the screen shows the time 00:37 and announces that the train arrives in 2457017 minutes, that’s in more than four years! What a bummer!

Ok, let’s compute backward.

  • The train arrived at 7:54 on September 2, 2024, Berlin daylight saving time, or 5:54 UTC.
  • When was 2457017 minutes earlier? Let’s find out with Python.

    In [1]: from datetime import datetime, timedelta
    
    In [2]: from zoneinfo import ZoneInfo
    
    In [3]: berlin = ZoneInfo("Europe/Berlin")
    
    In [4]: utc = ZoneInfo("UTC")
    
    In [5]: arrival = datetime(2024, 9, 2, 7, 54, tzinfo=berlin).astimezone(utc)
    
    In [6]: arrival.isoformat()
    Out[6]: '2024-09-02T05:54:00+00:00'
    
    In [7]: arrival_in = timedelta(minutes=2457017)
    
    In [8]: train_time = arrival - arrival_in
    
    In [9]: train_time.astimezone(berlin).isoformat()
    Out[9]: '2020-01-01T00:37:00+01:00'
    
  • The train clock was set to 00:37 on January 1, 2020.

It’s nice to see that this matches the time displayed on the screen, but it is from more than four years and eight months ago.


Not so fun fact: If you assumed everything will be fine as long as you stick to timezone-aware objects, you’ll have a bad time: timedelta arithmetics across the daylight savings time border yield unexpected results.

In [1]: from datetime import datetime, timedelta

In [2]: from zoneinfo import ZoneInfo

In [3]: berlin = ZoneInfo("Europe/Berlin")

In [4]: sat = datetime(2024, 10, 26, 21, 0, 0, tzinfo=berlin)

In [5]: sat.isoformat()
Out[5]: '2024-10-26T21:00:00+02:00'

In [6]: twelve_hours = timedelta(hours=12)

In [7]: (sat + twelve_hours).isoformat()
Out[7]: '2024-10-27T09:00:00+01:00'

The initial Saturday date is in the +02:00 timezone, i.e., daylight savings time, while the 12-hour shifted date is in +01:00, i.e., standard time. However, a person starting a stopwatch at 9 pm on Saturday DST and stopping it at 9 am on Sunday SDT would observe that 13 hours elapsed.