Skip to content

Commit

Permalink
github time now accounts for daylight saving
Browse files Browse the repository at this point in the history
Addresses #16 for daylight saving issue
  • Loading branch information
jym2584 authored Mar 24, 2022
1 parent 85f027b commit 3d932ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cloneRepositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ def run(self):
return

date_due = datetime.strptime(f'{self.__date_due} {self.__time_due}:00', '%Y-%m-%d %H:%M:%S')
date_repo = self.__repo.created_at + timedelta(hours = UTC_OFFSET)

time_local = datetime.now(datetime.now().astimezone().tzinfo) # get local time with offset
offset = time_local.utcoffset().total_seconds()/60/60 # get UTC offset, accounts for daylight saving
date_repo = self.__repo.created_at + timedelta(hours = offset) # convert github time to local

if date_due > date_repo: # clone only if the repo was created before the due date
self.clone_repo() # clones repo
Expand Down

0 comments on commit 3d932ca

Please sign in to comment.