Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BST O! what a mess #187

Open
kevindawson opened this issue Jul 28, 2020 · 0 comments
Open

BST O! what a mess #187

kevindawson opened this issue Jul 28, 2020 · 0 comments

Comments

@kevindawson
Copy link

kevindawson commented Jul 28, 2020

I was extracting Date from e-mail headers, when I came across this:

import maya
email_date = 'Tue, 22 May 2018 16:37:09 +01:00 (BST)'
print(maya.parse(email_date).datetime())

Output:

(kevin) kevin@dual:~/git/oldMail/sandbox$ python sand-001.py 
Traceback (most recent call last):
  File "sand-001.py", line 8, in <module>
    print(maya.parse(email_date).datetime())
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/maya/core.py", line 766, in parse
    dt = pendulum.parse(str(string), **options)
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/pendulum/parser.py", line 29, in parse
    return _parse(text, **options)
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/pendulum/parser.py", line 56, in _parse
    tz=parsed.tzinfo or options.get("tz", UTC),
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/pendulum/__init__.py", line 111, in datetime
    tz = _safe_timezone(tz)
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/pendulum/__init__.py", line 82, in _safe_timezone
    elif obj.tzname(None) == "UTC":
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/dateutil/tz/tz.py", line 238, in tzname
    return self._tznames[self._isdst(dt)]
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/dateutil/tz/tz.py", line 291, in _isdst
    dstval = self._naive_is_dst(dt)
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/dateutil/tz/tz.py", line 259, in _naive_is_dst
    timestamp = _datetime_to_timestamp(dt)
  File "/home/kevin/.local/share/virtualenvs/kevin-QvQG5PMg/lib/python3.7/site-packages/dateutil/tz/tz.py", line 1814, in _datetime_to_timestamp
    return (dt.replace(tzinfo=None) - EPOCH).total_seconds()
AttributeError: 'NoneType' object has no attribute 'replace'

Issues:

  • BST is not supported, but (GMT, CET, CEDT...) are

  • There is no error handling for Time Zone Abbreviations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant