I've been having problems with uploading files from different places on earth (different timezones). The problems were mainly about users getting 403 statuses from S3 (invalid signature or something).
Here's something I came up with – the theory:
In python…
from datetime import datetime
datetime.utcnow().isoformat()
# "2016-04-29T22:41:32.190085"
Now, I'm taking this string to the browser. In js console I type:
new Date("2016-04-29T22:41:32.190085").toUTCString()
// "Fri, 29 Apr 2016 20:41:32 GMT"
I'm GMT+200 and somehow I just lost 2 hours here. 22:41 UTC is 20:41 UTC now…
Append Z to date.isoformat(), because it's UTC and it's a good thing to say so explicitly (isoformat doesn't do it)
For peeps who don't use python backend from this repo I tell javascript to check if there's Z at the end of what the backend returns. If not I append one to ensure js is also working with UTC stuff.
Hope you like it and hope it solves problems, not causes them. ;) Please let me know what you think; merge if you like it.
Hello gents,
I've been having problems with uploading files from different places on earth (different timezones). The problems were mainly about users getting 403 statuses from S3 (invalid signature or something).
Here's something I came up with – the theory:
In python…
Now, I'm taking this string to the browser. In js console I type:
I'm
GMT+200
and somehow I just lost 2 hours here. 22:41 UTC is 20:41 UTC now…—
tl;dr
In this Pull Request I do 2 things:
Z
todate.isoformat()
, because it's UTC and it's a good thing to say so explicitly (isoformat
doesn't do it)Z
at the end of what the backend returns. If not I append one to ensure js is also working with UTC stuff.Hope you like it and hope it solves problems, not causes them. ;) Please let me know what you think; merge if you like it.
Cheers, Mariusz