s3tools / s3cmd

Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront).
https://s3tools.org/s3cmd
GNU General Public License v2.0
4.59k stars 905 forks source link

s3cmd 'ls' and 'get -p' doesn't respect timezone? #1195

Open yokoyama-flogics opened 3 years ago

yokoyama-flogics commented 3 years ago

Hello,

Thank you for the great software!

I have a question. My s3cmd version is 2.1.0 installed by HomeBrew on macOS 10.15.7. The underlying python is version 3.8.10.

I have an S3 bucket in US East (N. Virginia) us-east-1 region, and I have a file which has the following time stamp:

June 13, 2021, 05:55:02 (UTC+09:00)

The above was confirmed on the AWS console.

However, when I ran 's3cmd ls' on the same file, I saw the following. My PC's timezone is JST (UTC+9:00) as same as the above.

$ s3cmd ls s3://foobar/20210613/
2021-06-12 20:55      1480928  s3://foobar/20210613/mysql_all_20210613-045501.sql.xz

It looks s3cmd showed the date and time in UTC+0 (or simply GMT). Is this expected? Does s3cmd respect timezone by someway?

More confusingly, when I ran 's3cmd get' with '-p' option, the downloaded file had an incorrect timestamp as following.

$ ls -l
-rw-r--r--  1 yokoyama  staff    1480928  6 12 20:55 mysql_all_20210613-045501.sql.xz

To my understanding, it isn't preserving the correct time stamp. Shouldn't it be '6 13 05:55'?

Is my understanding incorrect??

Regards,

Atsushi

sirviot commented 5 months ago

We have this same issue.

When viewing content through browser it shows the correct timestamp in UTC.

https://mybucket / directory /

Last Modified                   Size           Key 
---------------------------------------------------------------------------------------------
                                               ../
2024-06-04T07:04:22.570Z        64.8 kB        somefile.png

After downloading the file with s3cmd get

Timezone is set to EEST

timedatectl status
...
       Time zone: Europe/Helsinki (EEST, +0300)

But ls command displays the UTC as localtime

ls -l somefile.png
... 2024-06-05 07:04 somefile.png

Also stat shows the UTC modification time as localtime

stat --format="%y" somefile.png
2024-06-05 07:04:22.000000000 +0300

This is wrong, and it should display

2024-06-05 10:04:22.000000000 +0300

The results are same no matter if I use --preserver or --no-preserve.