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

tools.time: fully utilize pytz to validate timezones #1707

Merged
merged 3 commits into from Nov 8, 2019

Conversation

dgw
Copy link
Member

@dgw dgw commented Oct 10, 2019

Instead of trying to coerce zone names all the way into something we can throw into an in pytz.all_timezones statement, all we have to do is rearrange the bits just enough to let pytz.timezone() take over. Its built-in normalization routines are plenty comprehensive, and if we make use of them there's no need to reinvent the wheel.

Updated the docstring for validate_timezone() to match. We aren't expecting that zone names like "EDT" will actually work. Neither 6.6.x nor the code this replaces will match that example, so we're not losing any functionality. Most of the three- and four-letter zone abbreviations I tried, in fact, fail because they aren't specific enough (might refer to one of multiple zones around the world). This is why we have the tz page users can visit if they don't know their local zone name, anyway.

Bonus spelling fixes included because if I didn't make them now, I'd forget and possibly miss them when going over this module's docs later.

Instead of trying to coerce zone names all the way into something we can
throw into an `in pytz.all_timezones` statement, all we have to do is
rearrange the bits just enough to let `pytz.timezone()` take over. Its
built-in normalization routines are plenty comprehensive, and if we make
use of them there's no need to reinvent the wheel.

Updated the docstring for `validate_timezone()` to match. We aren't
expecting that zone names like "EDT" will actually work. Neither 6.6.x
nor the code this replaces will match that example, so we're not losing
any functionality. Most of the three- and four-letter zone abbreviations
I tried, in fact, fail because they aren't specific enough (might refer
to one of multiple zones around the world). This is why we have the `tz`
page users can visit if they don't know their local zone name, anyway.

Bonus spelling fixes included because if I didn't make them now, I'd
forget and possibly miss them when going over this module's docs later.
@dgw dgw added this to the 7.0.0 milestone Oct 10, 2019
@dgw dgw requested a review from a team October 10, 2019 13:18
Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicks here and there, you can fix them if you want but that won't prevent me from approving this PR with joy.

sopel/tools/time.py Outdated Show resolved Hide resolved
sopel/tools/time.py Outdated Show resolved Hide resolved
sopel/tools/time.py Show resolved Hide resolved
dgw and others added 2 commits October 10, 2019 09:43
Co-Authored-By: Exirel <florian.strzelecki@gmail.com>
Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dgw dgw merged commit cdf1f6d into master Nov 8, 2019
@dgw dgw deleted the timezone-normalization branch November 8, 2019 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants