Try Getting Time from Server for List Calls
We have noticed that s5cmd ls sometimes fails to list objects immediately after they are written. This seems to be related to clock skew since s5cmd gets the current time from the client and compares it against each object's lastModified date. This is detailed a bit in issue #531
In our case, S3 servers seem to be a couple seconds ahead of our servers (which are synced with NTP servers so not sure where the issue lies). While troubleshooting, we did notice that the Date header from S3's http responses lined up with the future times we saw in the lastModified metadata.
This patch will request the Date header from the response and use it for the timestamp. It will fallback to the client's current time if the header is not present or in the event that the date cannot be parsed.
I've modified the tests to check for both scenarios and locally all unit test are working. Please let me know if there are any additional checks you'd like me to run.
I built this locally and it did now successfully return the future-dated (rounded up to the next whole second) object in our environment.