Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 68b2ae8

Browse files
committedApr 2, 2018
Fix #3006 - use documented dateutil API for time zone list
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 2d759c5 commit 68b2ae8

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Features
3838
Bugfixes
3939
--------
4040

41+
* Use documented dateutil API for time zone list (Issue #3006)
4142
* Handle trailing slash redirects with query strings correctly in
4243
``nikola serve`` (Issue #3000)
4344
* Fix w3c validation errors for itemscope entries in default themes

‎nikola/plugins/command/init.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,15 @@ def tzhandler(default, toconf):
384384

385385
if tz is None:
386386
print(" WARNING: Time zone not found. Searching list of time zones for a match.")
387-
zonesfile = tarfile.open(fileobj=dateutil.zoneinfo.getzoneinfofile_stream())
388-
zonenames = [zone for zone in zonesfile.getnames() if answer.lower() in zone.lower()]
389-
if len(zonenames) == 1:
390-
tz = dateutil.tz.gettz(zonenames[0])
391-
answer = zonenames[0]
387+
all_zones = dateutil.zoneinfo.get_zonefile_instance().zones
388+
matching_zones = [zone for zone in all_zones if answer.lower() in zone.lower()]
389+
if len(matching_zones) == 1:
390+
tz = dateutil.tz.gettz(matching_zones[0])
391+
answer = matching_zones[0]
392392
print(" Picking '{0}'.".format(answer))
393-
elif len(zonenames) > 1:
393+
elif len(matching_zones) > 1:
394394
print(" The following time zones match your query:")
395-
print(' ' + '\n '.join(zonenames))
395+
print(' ' + '\n '.join(matching_zones))
396396
continue
397397

398398
if tz is not None:

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
doit>=0.30.1
22
Pygments>=1.6
33
Pillow>=2.4.0
4-
python-dateutil>=2.4.0
4+
python-dateutil>=2.6.0
55
docutils>=0.13
66
mako>=1.0.0
77
Markdown>=2.4.0

0 commit comments

Comments
 (0)
Please sign in to comment.