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

Fix PytzUsageWarning for Python versions >= 3.6 #1062

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dateparser/date_parser.py
@@ -1,3 +1,5 @@
import sys

from tzlocal import get_localzone

from .timezone_parser import pop_tz_offset_from_string
Expand Down Expand Up @@ -31,7 +33,7 @@ def parse(self, date_string, parse_method, settings=None):
else:
if 'local' in _settings_tz:
stz = get_localzone()
if hasattr(stz, 'localize'):
if hasattr(stz, 'localize') and sys.version_info < (3, 6):
date_obj = stz.localize(date_obj)
else:
date_obj = date_obj.replace(tzinfo=stz)
Expand Down