From d47f9841753a7d43d5ed9d91a72fbc436ce3ab45 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 12 Aug 2023 21:12:49 +0000 Subject: [PATCH] Sagemaker: list_model_package(): Fixed a bug in CreationTime params (#6639) --- moto/sagemaker/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/moto/sagemaker/models.py b/moto/sagemaker/models.py index a5bf3c6da..726eab895 100644 --- a/moto/sagemaker/models.py +++ b/moto/sagemaker/models.py @@ -3,6 +3,7 @@ import os import random import string from datetime import datetime +from dateutil.tz import tzutc from typing import Any, Dict, List, Optional, Iterable, Union from moto.core import BaseBackend, BackendDict, BaseModel, CloudFormationModel @@ -994,7 +995,7 @@ class ModelPackage(BaseObject): _type="model-package", _id=model_package_name, ) - datetime_now = datetime.utcnow() + datetime_now = datetime.now(tzutc()) self.model_package_name = model_package_name self.model_package_group_name = model_package_group_name self.model_package_version = model_package_version @@ -2868,9 +2869,13 @@ class SageMakerModelBackend(BaseBackend): sort_order: Optional[str], ) -> List[ModelPackage]: if isinstance(creation_time_before, int): - creation_time_before_datetime = datetime.fromtimestamp(creation_time_before) + creation_time_before_datetime = datetime.fromtimestamp( + creation_time_before, tz=tzutc() + ) if isinstance(creation_time_after, int): - creation_time_after_datetime = datetime.fromtimestamp(creation_time_after) + creation_time_after_datetime = datetime.fromtimestamp( + creation_time_after, tz=tzutc() + ) if model_package_group_name is not None: model_package_type = "Versioned" model_package_summary_list = list(