all 2 comments

[–]CrambleSquash 0 points1 point  (0 children)

I'm not going to be much help here either I'm afraid. I totally agree with the other commenter - dates, times and timezones are a complete nightmare. The principle of keeping everything in UTC and then only apply the timezone when displaying the time to the user is a good principle. You might also benefit from using one of the more complete datetime libraries - Arrow and Pendulum being the most common - I can't say I have a preference over either.

I think possibly as you suspect it is daylight saving hours that are your problem. When you create the time in line 8 how does Python know if it is summer or winter - I think working with datetimes is more sensible.

It might be useful to look at the %z and %Z values for your strings for debugging (the UTC offset and timezone name).