Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…merge
  • Loading branch information...
commit c97c114177a2e1468698a5bdef298c4e16b490e7 2 parents 8161741 + 0f03a06
Matt Domsch authored July 14, 2012

Showing 1 changed file with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. 11  S3/Utils.py
11  S3/Utils.py
@@ -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 @@
16 17
 
17 18
 from logging import debug, info, warning, error
18 19
 
  20
+
19 21
 import Config
20 22
 import Exceptions
21 23
 
@@ -163,7 +165,14 @@ def formatSize(size, human_readable = False, floating_point = False):
163 165
 __all__.append("formatSize")
164 166
 
165 167
 def formatDateTime(s3timestamp):
166  
-    return time.strftime("%Y-%m-%d %H:%M", dateS3toPython(s3timestamp))
  168
+    try:
  169
+        import pytz
  170
+        timezone = pytz.timezone(os.environ.get('TZ', 'UTC'))
  171
+        utc_dt = datetime.datetime(*dateS3toPython(s3timestamp)[0:6], tzinfo=pytz.timezone('UTC'))
  172
+        dt_object = utc_dt.astimezone(timezone)
  173
+    except ImportError:
  174
+        dt_object = datetime.datetime(*dateS3toPython(s3timestamp)[0:6])
  175
+    return dt_object.strftime("%Y-%m-%d %H:%M")
167 176
 __all__.append("formatDateTime")
168 177
 
169 178
 def convertTupleListToDict(list):

0 notes on commit c97c114

Please sign in to comment.
Something went wrong with that request. Please try again.