-
Notifications
You must be signed in to change notification settings - Fork 40
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
exception UnknownTimeZoneError: 'Etc/GMT 3' #70
Comments
I faced the same problem and I wrote a wrapper around the middleware to avoid it: class TimezoneMiddleware(BaseTimezoneMiddleware):
def process_request(self, request):
try:
super().process_request(request)
except Exception:
logger.exception("Timezone Middleware Error") Apparently pytz would be fine if the timezone would have a plus or minus sign instead of a white-space: >>> import pytz
>>> import zoneinfo
>>> zonename = 'Etc/GMT+3'
>>> pytz.timezone(zonename)
<StaticTzInfo 'Etc/GMT+3'>
>>> zoneinfo.ZoneInfo(zonename)
zoneinfo.ZoneInfo(key='Etc/GMT+3')
>>> zonename = 'Etc/GMT-3'
>>> pytz.timezone(zonename)
<StaticTzInfo 'Etc/GMT-3'>
>>> zoneinfo.ZoneInfo(zonename)
zoneinfo.ZoneInfo(key='Etc/GMT-3')
>>> zonename = 'Etc/GMT 3'
>>> pytz.timezone(zonename)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/michel/.virtualenvs/teachermade/lib/python3.9/site-packages/pytz/__init__.py", line 188, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'Etc/GMT 3'
>>> zoneinfo.ZoneInfo(zonename)
Traceback (most recent call last):
File "/usr/lib/python3.9/zoneinfo/_common.py", line 12, in load_tzdata
return importlib.resources.open_binary(package_name, resource_name)
File "/usr/lib/python3.9/importlib/resources.py", line 91, in open_binary
return reader.open_resource(resource)
File "<frozen importlib._bootstrap_external>", line 1055, in open_resource
FileNotFoundError: [Errno 2] No such file or directory: '/home/michel/.virtualenvs/teachermade/lib/python3.9/site-packages/tzdata/zoneinfo/Etc/GMT 3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/zoneinfo/_common.py", line 24, in load_tzdata
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Etc/GMT 3' I didn't dig further to see what is causing timezone with this pattern (with a white space). |
The JS builds a wrong query string:
'&timezone=' + Intl.DateTimeFormat().resolvedOptions().timeZone
// -> '%timezone=Etc/GMT+6 The plus is then parsed as from urllib import parse
parse.parse_qs("timezone=Etc/GMT+6")
# -> {'timezone': ['Etc/GMT 6']} So there are a few steps required to fix this:
I'll prepare a PR. |
In version 0.5 this error occurs. The timezone entered is incorrect.
The text was updated successfully, but these errors were encountered: