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

UnknownTimezoneWarning #36

Open
Kirkman opened this issue May 29, 2020 · 2 comments
Open

UnknownTimezoneWarning #36

Kirkman opened this issue May 29, 2020 · 2 comments
Assignees

Comments

@Kirkman
Copy link

Kirkman commented May 29, 2020

Recently, when I use clarify, Python has been spitting out this warning:

UnknownTimezoneWarning: tzname
CDT identified but not understood.  
Pass "tzinfos" argument in order to correctly return a timezone-aware datetime. 
In a future version, this will raise an exception.

I think it's from this line in clarify:

return dateutil.parser.parse(tree.xpath('/ElectionResult/Timestamp')[0].text)

Anyway, it's not an exception yet, but I wanted to bring that to your attention. I don't know if something like this might be a solution, though obviously that specific answer is overkill.

@dwillis dwillis self-assigned this May 30, 2020
@dwillis
Copy link
Contributor

dwillis commented May 30, 2020

@Kirkman Hmm, yeah. That's weird, and thanks for raising it. Will see if there's something we can do.

@GPHemsley
Copy link
Collaborator

GPHemsley commented May 31, 2020

Here's the documentation for dateutil.parser.parse:
https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse

I've been unable to locate any example that does better than a hardcoded list of mappings, but dateutil.tz.gettz may be of some use:
https://dateutil.readthedocs.io/en/stable/tz.html#dateutil.tz.gettz

Python is notoriously bad at dealing with time and timezones, but perhaps knowledge of the source material will help here.

I'm guessing this will need to be passed something like:

{
    "AST": "America/Puerto_Rico",
    "EST": "EST5EDT",  # or "America/New_York"
    "EDT": "EST5EDT",  # or "America/New_York"
    "CST": "CST6CDT",  # or "America/Chicago"
    "CDT": "CST6CDT",  # or "America/Chicago"
    "MST": "MST7MDT",  # or "America/Denver"
    "MDT": "MST7MDT",  # or "America/Denver"
    "PST": "PST8PDT",  # or "America/Los_Angeles"
    "PDT": "PST8PDT",  # or "America/Los_Angeles"
    "AKST": "America/Anchorage",
    "AKDT": "America/Anchorage",
    "HAST": "America/Adak",
    "HADT": "America/Adak",
    "HST": "Pacific/Honolulu",
    "SST": "Pacific/Pago_Pago",
    "ChST": "Pacific/Guam",
    "CHST": "Pacific/Guam",
}

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

3 participants