Пример #1
0
 def format_eta(self):
     """Returns the attribute "eta" formatted as a string."""
     eta = self.fields['eta']
     if eta == -1:
         return 'not available'
     elif eta == -2:
         return 'unknown'
     else:
         return format_timedelta(self.eta)
Пример #2
0
 def testFormatTimedelta(self):
     table = {
         datetime.timedelta(0, 0): "0 00:00:00",
         datetime.timedelta(0, 10): "0 00:00:10",
         datetime.timedelta(0, 60): "0 00:01:00",
         datetime.timedelta(0, 61): "0 00:01:01",
         datetime.timedelta(0, 3661): "0 01:01:01",
         datetime.timedelta(1, 3661): "1 01:01:01",
         datetime.timedelta(13, 65660): "13 18:14:20",
     }
     for delta, expected in iter(table.items()):
         self.assertEqual(tu.format_timedelta(delta), expected)
Пример #3
0
 def testFormatTimedelta(self):
     table = {
         datetime.timedelta(0, 0): '0 00:00:00',
         datetime.timedelta(0, 10): '0 00:00:10',
         datetime.timedelta(0, 60): '0 00:01:00',
         datetime.timedelta(0, 61): '0 00:01:01',
         datetime.timedelta(0, 3661): '0 01:01:01',
         datetime.timedelta(1, 3661): '1 01:01:01',
         datetime.timedelta(13, 65660): '13 18:14:20',
     }
     for delta, expected in iteritems(table):
         self.assertEqual(tu.format_timedelta(delta), expected)
Пример #4
0
    def format_eta(self):
        """
        Returns the attribute *eta* formatted as a string.

        * If eta is -1 the result is 'not available'
        * If eta is -2 the result is 'unknown'
        * Otherwise eta is formatted as <days> <hours>:<minutes>:<seconds>.
        """
        eta = self._fields["eta"].value
        if eta == -1:
            return "not available"
        elif eta == -2:
            return "unknown"
        else:
            return format_timedelta(self.eta)
Пример #5
0
    def format_eta(self):
        """
        Returns the attribute *eta* formatted as a string.

        * If eta is -1 the result is 'not available'
        * If eta is -2 the result is 'unknown'
        * Otherwise eta is formatted as <days> <hours>:<minutes>:<seconds>.
        """
        eta = self._fields['eta'].value
        if eta == -1:
            return 'not available'
        elif eta == -2:
            return 'unknown'
        else:
            return format_timedelta(self.eta)