Skip to content

Commit

Permalink
Update update.py
Browse files Browse the repository at this point in the history
Update when the weekday has changed rather than when 24 hours has elapsed
  • Loading branch information
Rod-Persky authored Mar 29, 2018
1 parent ca6f3d6 commit a66cf99
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Investoscope Updater.app/Contents/Resources/update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from datetime import date
import pickle
import copy

Expand Down Expand Up @@ -45,9 +46,9 @@ def get_quote(item):
def check_item_outdated(item, status):
""" Check if the item is outdated """
if item['code'] in status:
state = status[item['code']]
# If item is older than 1 day (86400 seconds), then update
if state < (int(time.time())-86400):
# Update when the weekday has changed
last_update = date.fromtimestamp(status[item['code']])
if last_update.weekday() is not date.today().weekday():
return True
else:
return False
Expand Down

0 comments on commit a66cf99

Please sign in to comment.