Esempio n. 1
0
 def date_to_key(self, date):
    diff = get_today() - date
    if diff.days < 0:
       return 'the future'
    elif diff.days == 0:
       return 'last sync'
    else:
       return '%d days ago' % diff.days
Esempio n. 2
0
 def sync(self):
    swap = self.path + '~'
    backup = self.path + '.backup-%d' % now().weekday()
    with open(swap, 'w') as s:
       s.write(dumps({'tasks': self.tasks, 'events': self.events, 'day': get_today()}))
       if os.path.exists(self.path):
          os.rename(self.path, backup)
       os.rename(swap, self.path)
Esempio n. 3
0
 def offset(self):
    if self.date is None:
       return -TaskDate.FUTURE
    elif self.date == TaskDate.FUTURE:
       return TaskDate.FUTURE
    elif self.date == TaskDate.SOON:
       return 3
    return (self.date - get_today()).days
Esempio n. 4
0
 def __init__(self, offset_days=None, date=None):
    if date:
       self.date = date
    elif offset_days is None:
       self.date = None
    elif offset_days is TaskDate.FUTURE:
       self.date = TaskDate.FUTURE
    elif offset_days is TaskDate.SOON:
       self.date = TaskDate.SOON
    else:
       self.date = get_today() + make_timedelta(offset_days)