diff --git a/moto/core/utils.py b/moto/core/utils.py index 921f64be..c9bf9347 100644 --- a/moto/core/utils.py +++ b/moto/core/utils.py @@ -190,6 +190,12 @@ def iso_8601_datetime_without_milliseconds(datetime): return None if datetime is None else datetime.strftime("%Y-%m-%dT%H:%M:%S") + "Z" +def iso_8601_datetime_without_milliseconds_s3(datetime): + return ( + None if datetime is None else datetime.strftime("%Y-%m-%dT%H:%M:%S.000") + "Z" + ) + + RFC1123 = "%a, %d %b %Y %H:%M:%S GMT" diff --git a/moto/s3/models.py b/moto/s3/models.py index 23304043..e5237168 100644 --- a/moto/s3/models.py +++ b/moto/s3/models.py @@ -22,7 +22,7 @@ import six from bisect import insort from moto.core import ACCOUNT_ID, BaseBackend, BaseModel -from moto.core.utils import iso_8601_datetime_with_milliseconds, rfc_1123_datetime +from moto.core.utils import iso_8601_datetime_without_milliseconds_s3, rfc_1123_datetime from moto.cloudwatch.models import MetricDatum from moto.utilities.tagging_service import TaggingService from .exceptions import ( @@ -79,7 +79,7 @@ class FakeDeleteMarker(BaseModel): @property def last_modified_ISO8601(self): - return iso_8601_datetime_with_milliseconds(self.last_modified) + return iso_8601_datetime_without_milliseconds_s3(self.last_modified) @property def version_id(self): @@ -206,7 +206,7 @@ class FakeKey(BaseModel): @property def last_modified_ISO8601(self): - return iso_8601_datetime_with_milliseconds(self.last_modified) + return iso_8601_datetime_without_milliseconds_s3(self.last_modified) @property def last_modified_RFC1123(self):