1 |
floppym 11/08/29 00:37:47 |
2 |
|
3 |
Added: transmissionrpc-timestamp-test.patch |
4 |
Log: |
5 |
New package for bug 377565 |
6 |
|
7 |
(Portage version: 2.2.0_alpha51/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-python/transmissionrpc/files/transmissionrpc-timestamp-test.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/transmissionrpc/files/transmissionrpc-timestamp-test.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/transmissionrpc/files/transmissionrpc-timestamp-test.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: transmissionrpc-timestamp-test.patch |
16 |
=================================================================== |
17 |
# HG changeset patch |
18 |
# User Mike Gilbert <floppymaster@×××××.com> |
19 |
# Date 1312249052 14400 |
20 |
# Node ID 144110dc47fae14f2692afa1be1e57d461b7393e |
21 |
# Parent 4fe71eb818d0a220b8fe6370fa00c997e7f12e4b |
22 |
Use UTC for utils.format_timestamp unit test. |
23 |
|
24 |
This removes dependence on the local time zone when running tests. |
25 |
|
26 |
diff --git a/test/utils.py b/test/utils.py |
27 |
--- a/test/utils.py |
28 |
+++ b/test/utils.py |
29 |
@@ -55,11 +55,11 @@ |
30 |
def testFormatTimestamp(self): |
31 |
table = { |
32 |
0: '-', |
33 |
- 1: '1970-01-01 01:00:01', |
34 |
- 1129135532: '2005-10-12 18:45:32', |
35 |
+ 1: '1970-01-01 00:00:01', |
36 |
+ 1129135532: '2005-10-12 16:45:32', |
37 |
} |
38 |
for timestamp, expected in table.iteritems(): |
39 |
- self.assertEqual(tu.format_timestamp(timestamp), expected) |
40 |
+ self.assertEqual(tu.format_timestamp(timestamp, utc=True), expected) |
41 |
|
42 |
def testInetAddress(self): |
43 |
table = { |
44 |
@@ -97,4 +97,4 @@ |
45 |
return suite |
46 |
|
47 |
if __name__ == '__main__': |
48 |
- unittest.main() |
49 |
\ No newline at end of file |
50 |
+ unittest.main() |
51 |
diff --git a/transmissionrpc/utils.py b/transmissionrpc/utils.py |
52 |
--- a/transmissionrpc/utils.py |
53 |
+++ b/transmissionrpc/utils.py |
54 |
@@ -34,12 +34,15 @@ |
55 |
hours, minutes = divmod(minutes, 60) |
56 |
return '%d %02d:%02d:%02d' % (delta.days, hours, minutes, seconds) |
57 |
|
58 |
-def format_timestamp(timestamp): |
59 |
+def format_timestamp(timestamp, utc=False): |
60 |
""" |
61 |
Format unix timestamp into ISO date format. |
62 |
""" |
63 |
if timestamp > 0: |
64 |
- dt_timestamp = datetime.datetime.fromtimestamp(timestamp) |
65 |
+ if utc: |
66 |
+ dt_timestamp = datetime.datetime.utcfromtimestamp(timestamp) |
67 |
+ else: |
68 |
+ dt_timestamp = datetime.datetime.fromtimestamp(timestamp) |
69 |
return dt_timestamp.isoformat(' ') |
70 |
else: |
71 |
return '-' |