Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)