Skip to content

Commit

Permalink
refactoring check_timezone function
Browse files Browse the repository at this point in the history
  • Loading branch information
ishepard committed Jan 14, 2019
1 parent 1c7d625 commit e784023
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pydriller/repository_mining.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,14 @@ def _has_modification_with_file_type(self, commit):

def _check_timezones(self):
if self._since is not None:
if self._since.tzinfo is None or self._since.tzinfo.utcoffset(self._since) is None:
self._since = self._since.replace(tzinfo=pytz.utc)
self._since = self._replace_timezone(self._since)
if self._to is not None:
if self._to.tzinfo is None or self._to.tzinfo.utcoffset(self._to) is None:
self._to = self._to.replace(tzinfo=pytz.utc)
self._to = self._replace_timezone(self._to)

def _replace_timezone(self, dt: datetime):
if dt.tzinfo is None or dt.tzinfo.utcoffset(dt) is None:
dt = dt.replace(tzinfo=pytz.utc)
return dt

def _get_repo_name_from_url(self, url: str) -> str:
last_slash_index = url.rfind("/")
Expand Down

0 comments on commit e784023

Please sign in to comment.