Skip to content

Commit

Permalink
Fix PytzUsageWarning for Python versions >= 3.6 (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaildawoodjee committed Jun 20, 2022
1 parent a7ca7a5 commit 0ed979e
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit 0ed979e

Please sign in to comment.