Beispiel #1
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)
Beispiel #2
0
 def parse_timestring(cls, timestring):
     hours = 0
     minutes = 0
     timestring = filter(lambda c: c.isdigit() or c in ":apm", timestring)
     if timestring.endswith("pm") or timestring.endswith("am"):
         if timestring.endswith("pm"):
             hours += 12
         timestring = timestring[:-2]
     m = timestring.split(":")
     if len(m) > 0:
         try:
             x = int(m[0])
             if x == 12 and hours == 12:
                 pass
             else:
                 hours += x
         except:
             pass
     if len(m) > 1:
         try:
             minutes = int(m[1])
         except:
             pass
     return make_timedelta(hours=hours, minutes=minutes)