clarify icon indicating copy to clipboard operation
clarify copied to clipboard

UnknownTimezoneWarning

Open Kirkman opened this issue 4 years ago • 2 comments

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: https://github.com/openelections/clarify/blob/12b4eb5ff19bbd7641395d1b7f035eed45a9abd6/clarify/parser.py#L67

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.

Kirkman avatar May 29 '20 03:05 Kirkman

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

dwillis avatar May 30 '20 20:05 dwillis

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",
}

GPHemsley avatar May 31 '20 02:05 GPHemsley