Browse code

Merge remote-tracking branch 'Roguelazer/tz_support' into Roguelazer-merge

Matt Domsch authored on 2012/07/15 05:38:53
Showing 1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 ##         http://www.logix.cz/michal
4 4
 ## License: GPL Version 2
5 5
 
6
+import datetime
6 7
 import os
7 8
 import sys
8 9
 import time
... ...
@@ -16,6 +17,7 @@ import errno
16 16
 
17 17
 from logging import debug, info, warning, error
18 18
 
19
+
19 20
 import Config
20 21
 import Exceptions
21 22
 
... ...
@@ -163,7 +165,14 @@ def formatSize(size, human_readable = False, floating_point = False):
163 163
 __all__.append("formatSize")
164 164
 
165 165
 def formatDateTime(s3timestamp):
166
-    return time.strftime("%Y-%m-%d %H:%M", dateS3toPython(s3timestamp))
166
+    try:
167
+        import pytz
168
+        timezone = pytz.timezone(os.environ.get('TZ', 'UTC'))
169
+        utc_dt = datetime.datetime(*dateS3toPython(s3timestamp)[0:6], tzinfo=pytz.timezone('UTC'))
170
+        dt_object = utc_dt.astimezone(timezone)
171
+    except ImportError:
172
+        dt_object = datetime.datetime(*dateS3toPython(s3timestamp)[0:6])
173
+    return dt_object.strftime("%Y-%m-%d %H:%M")
167 174
 __all__.append("formatDateTime")
168 175
 
169 176
 def convertTupleListToDict(list):