jordansissel/s3cleaner — Issue #3: When local system timezone is not set to GMT --max-age parameter doesn't work as expected
Author: rufrancis
Created: 2012-02-26 15:45:51+00:00
State: open

S3 returns the last_modified date in GMT, if the local system has a timezone different from GMT, the following lines will produce undesired behavior.

mtime = time.mktime(time.strptime(key.last_modified.split(".")[0], "%Y-%m-%dT%H:%M:%S"))
now = time.time();

mtime will be relative to GMT where now will be relative to the users localtime which makes the behavior of the --max-age parameter somewhat unexpected. To fix this, the local time should be calculated in the same timezone as mtime which can be done by replacing the second line with this.

now = time.mktime(time.gmtime())