Arrow: Test formatter against full timezone database

Created on 20 Oct 2019  路  7Comments  路  Source: arrow-py/arrow

Similar to https://github.com/crsmithdev/arrow/issues/657, it would be great to test the timezone formatter against this DB as well.

Code for tests could go here: https://github.com/crsmithdev/arrow/blob/master/tests/formatter_tests.py#L122.

good first issue tests

Most helpful comment

Hi!
For the dateutil zones I'm using the tzname:

dateutil_abbv = [datetime.now(gettz(tz)).tzname() for tz in dateutil_zones]

For the pyzt zones, I am using this:

pytz_abbv = [datetime.now(pytz.timezone(tz)).strftime('%Z') for tz in pytz_zones]

All 7 comments

Hi, can I take this?

@haneybarg yes, go for it! If you need help, do not hesitate to reach out :).

Hi! I've made progress, but it seems that there exists more than one timezone for the same abbreviation. Ex: CST can be Asia/Macao or Asia/Shanghai. Therefore, I can not use the same dict format, with abbreviations as keys. How should I proceed?

Hi @haneybarg, that is an interesting concern. I think the best approach may be to create a function similar to make_full_tz_list in parser_tests.py, which was added in https://github.com/crsmithdev/arrow/pull/692. We need to find a way to create a mapping of abbreviations to full timezone name using dateutil and pytz. I am going to do a bit of research. Let me know if you figure out something yourself as well. @systemcatch any ideas as well?

Hi! I've found functions in the pyzt and dateutil docs that do the mapping from timezones to abbreviation. I was thinking of using the abbreviation as a key, with the respective timezones in a list, similar to the make_full_tz_list, like:
{
"CST": ["Asia/Macao", "Asia/Shanghai"],
"CET": ....
.....
}

Fantastic. I think that could very well work. Which functions in pytz and dateutil are you using? I am very curious.

Hi!
For the dateutil zones I'm using the tzname:

dateutil_abbv = [datetime.now(gettz(tz)).tzname() for tz in dateutil_zones]

For the pyzt zones, I am using this:

pytz_abbv = [datetime.now(pytz.timezone(tz)).strftime('%Z') for tz in pytz_zones]
Was this page helpful?
0 / 5 - 0 ratings