Skip to content

Commit

Permalink
Fix issue with date not syncing. Also partially fix \#3 issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
programmerPhysicist committed Dec 29, 2023
1 parent ff6d10e commit d9d76a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
11 changes: 9 additions & 2 deletions source/habitica.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ def get_all_habtasks(auth):
url = 'https://habitica.com/api/v3/tasks/user/'
# TODO: handle error cases for response
response = requests.get(url,headers=auth)
hab_raw = response.json()
hab_tasklist = hab_raw['data'] #FINALLY getting something I can work with... this will be a list of dicts I want to turn into a list of objects with class hab_tasks. Hrm. Weeeelll, if I make a class elsewhere....
if response.ok == True:
hab_raw = response.json()
"""FINALLY getting something I can work with... this will be a list of
dicts I want to turn into a list of objects with class hab_tasks.
Hrm. Weeeelll, if I make a class elsewhere...."""
hab_tasklist = hab_raw['data']
else:
hab_tasklist = []
print(response.reason)

#keeping records of all our tasks
hab_tasks = []
Expand Down
1 change: 1 addition & 0 deletions source/oneWaySync.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def sync_todoist_to_habitica():
newDict = new_hab.task_dict
r = main.write_hab_task(newDict)
if r.ok == False:
#TODO: check ['errors'], due to it sometimes not having it
errMsg = r.json()['errors'][0]['message']
alias = r.json()['errors'][0]['value']
print("Error Code "+str(r.status_code)+": \""
Expand Down
12 changes: 6 additions & 6 deletions source/todo_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,19 @@ def complete(self, status):
@property
#due date
def due_date(self):
return self.__task_dict['due_date_utc']
return self.__task_dict['due']

@due_date.setter
def due_date(self, date):
self.__task_dict['due_date_utc'] = date
self.__task_dict['due'] = date

@property
#due date
def due(self):
from dateutil import parser
import datetime
if self.__task_dict['due_date_utc'] != None:
date = parser.parse(self.__task_dict['due_date_utc'])
if self.__task_dict['due'] != None:
date = parser.parse(self.__task_dict['due']['date'])
return date
else:
return ''
Expand All @@ -141,7 +141,7 @@ def dueToday(self):
import pytz
today = datetime.utcnow().replace(tzinfo=pytz.UTC)
try:
wobble = parser.parse(self.__task_dict['due_date_utc']) - timedelta(hours=6) #that datetime thing is pulling todoist's due dates to my time zone
wobble = parser.parse(self.__task_dict['due']) - timedelta(hours=6) #that datetime thing is pulling todoist's due dates to my time zone
dueDate = wobble.date()
except:
dueDate = ""
Expand All @@ -167,7 +167,7 @@ def dueLater(self):
import pytz
today = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
try:
wobble = parser.parse(self.__task_dict['due_date_utc'])
wobble = parser.parse(self.__task_dict['due'])
dueDate = wobble.date()
except:
dueDate = ""
Expand Down

0 comments on commit d9d76a5

Please sign in to comment.