You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing some odd behaviour here between the Linux (on a Raspberry Pi) and Windows.
Firstly, dateutil._version.version gives me 2.9.0.post0 on both systems. Linux is running Python 3.11.2 and Windows is running Python 3.10.11.
I am in the UK, so local timezone is (as of this morning) BST, which is UTC+01:00. Both of the machines I'm running this on a
Here's my test code:
from dateutil import parser
t_str = '2024-03-31 02:00:25 BST+0100'
t = parser.parse(t_str)
print(t.tzinfo())
# Linux : tzlocal()
# Windows : tzoffset('BST', -3600)
print(t.timestamp())
# Linux : 1711846825.0
# Windows : 1711854025.0
So it appears that something on Windows is treating the BST+0100 as an hour offset the other way. (If I change the string to be BST-0100 it does it to +3600)
The string I'm getting here is coming from an external source, so I can't change the format of it.
If I import tzlocal and run tzlocal.get_localzone() on both machines, I get Europe/London on both
Any idea why this is happening? Am I doing something wrong, or is this a bug in the parser somewhere along the way?
The text was updated successfully, but these errors were encountered:
I found that passing in tzinfos={"GMT": 0, "BST": 3600} fixed my issue. Without this, though, I'm not sure why it wasn't just ignoring the BST/GMT in the string and using the +0100 as the offset.
I'm seeing some odd behaviour here between the Linux (on a Raspberry Pi) and Windows.
Firstly,
dateutil._version.version
gives me2.9.0.post0
on both systems. Linux is running Python 3.11.2 and Windows is running Python 3.10.11.I am in the UK, so local timezone is (as of this morning) BST, which is UTC+01:00. Both of the machines I'm running this on a
Here's my test code:
So it appears that something on Windows is treating the
BST+0100
as an hour offset the other way. (If I change the string to beBST-0100
it does it to +3600)The string I'm getting here is coming from an external source, so I can't change the format of it.
If I import
tzlocal
and runtzlocal.get_localzone()
on both machines, I getEurope/London
on bothAny idea why this is happening? Am I doing something wrong, or is this a bug in the parser somewhere along the way?
The text was updated successfully, but these errors were encountered: