Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 377565
Collapse All | Expand All

(-)a/test/utils.py (-4 / +4 lines)
Lines 55-65 Link Here
55
    def testFormatTimestamp(self):
55
    def testFormatTimestamp(self):
56
        table = {
56
        table = {
57
            0: '-',
57
            0: '-',
58
            1: '1970-01-01 01:00:01',
58
            1: '1970-01-01 00:00:01',
59
            1129135532: '2005-10-12 18:45:32',
59
            1129135532: '2005-10-12 16:45:32',
60
        }
60
        }
61
        for timestamp, expected in table.iteritems():
61
        for timestamp, expected in table.iteritems():
62
            self.assertEqual(tu.format_timestamp(timestamp), expected)
62
            self.assertEqual(tu.format_timestamp(timestamp, utc=True), expected)
63
    
63
    
64
    def testInetAddress(self):
64
    def testInetAddress(self):
65
        table = {
65
        table = {
Lines 97-100 Link Here
97
    return suite
97
    return suite
98
98
99
if __name__ == '__main__':
99
if __name__ == '__main__':
100
    unittest.main()
100
    unittest.main()
(-)a/transmissionrpc/utils.py (-2 / +5 lines)
Lines 34-45 Link Here
34
    hours, minutes = divmod(minutes, 60)
34
    hours, minutes = divmod(minutes, 60)
35
    return '%d %02d:%02d:%02d' % (delta.days, hours, minutes, seconds)
35
    return '%d %02d:%02d:%02d' % (delta.days, hours, minutes, seconds)
36
36
37
def format_timestamp(timestamp):
37
def format_timestamp(timestamp, utc=False):
38
    """
38
    """
39
    Format unix timestamp into ISO date format.
39
    Format unix timestamp into ISO date format.
40
    """
40
    """
41
    if timestamp > 0:
41
    if timestamp > 0:
42
        dt_timestamp = datetime.datetime.fromtimestamp(timestamp)
42
        if utc:
43
            dt_timestamp = datetime.datetime.utcfromtimestamp(timestamp)
44
        else:
45
            dt_timestamp = datetime.datetime.fromtimestamp(timestamp)
43
        return dt_timestamp.isoformat(' ')
46
        return dt_timestamp.isoformat(' ')
44
    else:
47
    else:
45
        return '-'
48
        return '-'

Return to bug 377565