tools.time: fully utilize pytz to validate timezones #1707
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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 letpytz.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 thetz
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.