def __call__(self, task): if not task.dueDate: return "", None delta = task.dueDate - self.today if delta.days != 0: value = task.dueDate.strftime("%x %H:%M") else: value = task.dueDate.strftime("%H:%M") if self.shortFormat: value = ydateutils.formatTimeDelta(delta) else: value += " (%s)" % ydateutils.formatTimeDelta(delta) color = colorizer(delta.days * 33, reverse=True) return value, color
def testFormatTimeDelta(self): testData = [ (timedelta(minutes=1), "1m"), (timedelta(days=2, hours=5), "2d"), (timedelta(days=7), "1w"), (timedelta(days=10), "1w, 3d"), (timedelta(days=60), "2M"), (timedelta(days=80), "2M, 20d"), (timedelta(days=365), "1Y"), (timedelta(days=400), "1Y, 1M"), ] for input, expected in testData: output = ydateutils.formatTimeDelta(input) self.assertEquals(expected, output) output = ydateutils.formatTimeDelta(-input) self.assertEquals("-" + expected, output)
def __call__(self, task): delta = self.today - task.creationDate.replace(microsecond=0) if self.asDate: return task.creationDate.strftime("%x %H:%M"), None else: return ydateutils.formatTimeDelta(delta), colorizer(delta.days)
def __call__(self, task): delta = self.today - task.creationDate if self.asDate: return unicode(task.creationDate), None else: return ydateutils.formatTimeDelta(delta), colorizer(delta.days)