From 94ef88e6fba230e01f7fa7d383b5c6345a009b6a Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Fri, 1 Dec 2023 15:34:52 +0100 Subject: [PATCH] return offset-aware modification time (#818) --- s3fs/core.py | 2 +- s3fs/tests/test_s3fs.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/s3fs/core.py b/s3fs/core.py index 64fb1443..e9e8d8f8 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -1992,7 +1992,7 @@ def modified(self, path, version_id=None, refresh=False): if "LastModified" not in info: # This path is a bucket or folder, which do not currently have a modified date raise IsADirectoryError - return info["LastModified"].replace(tzinfo=None) + return info["LastModified"] def sign(self, path, expiration=100, **kwargs): return self.url(path, expires=expiration, **kwargs) diff --git a/s3fs/tests/test_s3fs.py b/s3fs/tests/test_s3fs.py index 173fcef4..d2c12570 100644 --- a/s3fs/tests/test_s3fs.py +++ b/s3fs/tests/test_s3fs.py @@ -2033,6 +2033,7 @@ def test_modified(s3): s3.touch(file_path) modified = s3.modified(path=file_path) assert isinstance(modified, datetime.datetime) + assert modified.tzinfo is not None # Test directory with pytest.raises(IsADirectoryError):