Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions source/one_way_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,9 @@ def sync_todoist_to_habitica():
todoist_tasks, todo_api = get_tasks(todo_token) # todoist_tasks used to be tod_tasks

tod_tasks = []
tzone = None
for task in todoist_tasks:
tod_tasks.append(TodTask(task))

if tzone is None:
# assumption is that timezone from Todoist
# is the same as local timezone
tzone = pytz.timezone(str(get_localzone()))

for task in tod_tasks:
if task.due != '':
task.due_date = task.due.astimezone(tzone)

# TODO: add back to filter out repeating older than a certain amount?
# date stuff
# today = datetime.now()
Expand Down
9 changes: 8 additions & 1 deletion source/todo_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from builtins import *
from datetime import datetime
from tzlocal import get_localzone
import pytz

Check warning

Code scanning / Pylint (reported by Codacy)

third party import "import pytz" should be placed before "from tzlocal import get_localzone" Warning

third party import "import pytz" should be placed before "from tzlocal import get_localzone"

Check warning

Code scanning / Prospector (reported by Codacy)

third party import "import pytz" should be placed before "from tzlocal import get_localzone" (wrong-import-order) Warning

third party import "import pytz" should be placed before "from tzlocal import get_localzone" (wrong-import-order)


#from .dates import parse_date_utc
Expand Down Expand Up @@ -38,6 +39,9 @@

self.__task_dict = task_dict

tzone = pytz.timezone(str(get_localzone()))
self.__task_dict['due']['date'] = self.due.astimezone(tzone)

@property
#Get the task dictionary as is
def task_dict(self):
Expand Down Expand Up @@ -128,7 +132,10 @@
from dateutil import parser
import datetime
if self.__task_dict['due'] is not None:
date = parser.parse(self.__task_dict['due']['date'])
if isinstance(self.__task_dict['due'], dict):
date = parser.parse(self.__task_dict['due']['date'])
else:
date = self.__task_dict['due']
return date
return ''

Expand Down
Loading
Loading