|
|
|
@@ -4,23 +4,26 @@ from datetime import date, time, datetime, timedelta |
|
|
|
import gi |
|
|
|
gi.require_version('Gio', '2.0') |
|
|
|
from gi.repository import Gio |
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
##@brief Simple function to parse string from api to a datetimeformat. |
|
|
|
# @param datastr String with date |
|
|
|
# @return datetime object with date as specified in string. |
|
|
|
def makedatetime(datestr): |
|
|
|
if datestr == None: |
|
|
|
return None |
|
|
|
return datetime.strptime(datestr,"%Y-%m-%d") |
|
|
|
|
|
|
|
##@brief Simple function to parse iso formated string from api to a datetimeformat. |
|
|
|
# @param datastr String with date and time in iso format |
|
|
|
# @return datetime object with date as specified in string. |
|
|
|
def fromisoformat(datestr): |
|
|
|
if datestr == None: |
|
|
|
return None |
|
|
|
return datetime.strptime(datestr,"%Y-%m-%dT%H:%M:%SZ") |
|
|
|
# Matches on YYYY-MM-DD, does not check if date is in range. Ex: 2019-11-08 |
|
|
|
if (re.match(r'^\d{4}-\d{2}-\d{2}$',datestr, 0) != None): |
|
|
|
return datetime.strptime(datestr,"%Y-%m-%d") |
|
|
|
# Matches on YYYY-MM-DDTHH:MM:SSZ, does not check if date is in range. Ex: 2019-11-08T15:45:02Z |
|
|
|
if (re.match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$',datestr, 0) != None): |
|
|
|
return datetime.strptime(datestr,"%Y-%m-%dT%H:%M:%SZ") |
|
|
|
# Matches on YYYY-MM-DDTHH:MM:SS, does not check if date is in range. Ex: 2019-11-08T15:45:02 |
|
|
|
if (re.match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$',datestr, 0) != None): |
|
|
|
return datetime.strptime(datestr,"%Y-%m-%dT%H:%M:%S") |
|
|
|
else: |
|
|
|
return None |
|
|
|
|
|
|
|
class TodoProject: |
|
|
|
''' Common class for api calls''' |
|
|
|
@@ -174,7 +177,7 @@ class TodoItem: |
|
|
|
self._due = item["due"] |
|
|
|
#check if due is set. |
|
|
|
if self._due != None: |
|
|
|
self.due_date = makedatetime(self._due["date"]) |
|
|
|
self.due_date = fromisoformat(self._due["date"]) |
|
|
|
self.due_timezone = self._due["timezone"] |
|
|
|
self.due_string = self._due["string"] |
|
|
|
self.due_lang = self._due["lang"] |
|
|
|
|