Skip to content
This repository has been archived by the owner on Nov 4, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'Roguelazer/tz_support' into Roguelazer-…
Browse files Browse the repository at this point in the history
…merge
  • Loading branch information
Matt Domsch authored and Matt Domsch committed Jul 14, 2012
2 parents 8161741 + 0f03a06 commit c97c114
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion S3/Utils.py
Expand Up @@ -3,6 +3,7 @@
## http://www.logix.cz/michal
## License: GPL Version 2

import datetime
import os
import sys
import time
Expand All @@ -16,6 +17,7 @@

from logging import debug, info, warning, error


import Config
import Exceptions

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c97c114

Please sign in to comment.