Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Respect the $TZ environment variable to show local times if requested

  • Loading branch information...
commit 0f03a064cd087d9f52ef28bb67aa56a41ee00fcf 1 parent 19a529a
@Roguelazer authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 S3/Utils.py
View
11 S3/Utils.py
@@ -3,6 +3,7 @@
## http://www.logix.cz/michal
## License: GPL Version 2
+import datetime
import os
import sys
import time
@@ -16,6 +17,7 @@
from logging import debug, info, warning, error
+
import Config
import Exceptions
@@ -163,7 +165,14 @@ def formatSize(size, human_readable = False, floating_point = False):
__all__.append("formatSize")
def formatDateTime(s3timestamp):
- return time.strftime("%Y-%m-%d %H:%M", dateS3toPython(s3timestamp))
+ try:
+ import pytz
+ timezone = pytz.timezone(os.environ.get('TZ', 'UTC'))
+ utc_dt = datetime.datetime(*dateS3toPython(s3timestamp)[0:6], tzinfo=pytz.timezone('UTC'))
+ dt_object = utc_dt.astimezone(timezone)
+ except ImportError:
+ dt_object = datetime.datetime(*dateS3toPython(s3timestamp)[0:6])
+ return dt_object.strftime("%Y-%m-%d %H:%M")
__all__.append("formatDateTime")
def convertTupleListToDict(list):
Please sign in to comment.
Something went wrong with that request. Please try again.