From 9b62e0efbf1a5af50a6797a537311521026c0028 Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE Date: Fri, 27 Oct 2023 07:44:34 +0200 Subject: [PATCH] fix(matrix-service): do not use the `timezone.utc` timezone to preserve a naive datetime --- antarest/matrixstore/service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/antarest/matrixstore/service.py b/antarest/matrixstore/service.py index 639084b587..fbc5e0d8c3 100644 --- a/antarest/matrixstore/service.py +++ b/antarest/matrixstore/service.py @@ -5,7 +5,7 @@ import tempfile import zipfile from abc import ABC, abstractmethod -from datetime import datetime, timezone +from datetime import datetime from pathlib import Path from typing import List, Optional, Sequence, Tuple, Union @@ -154,11 +154,13 @@ def create(self, data: Union[List[List[MatrixData]], npt.NDArray[np.float64]]) - matrix_id = self.matrix_content_repository.save(data) shape = data.shape if isinstance(data, np.ndarray) else (len(data), len(data[0]) if data else 0) with db(): + # Do not use the `timezone.utc` timezone to preserve a naive datetime. + created_at = datetime.utcnow() matrix = Matrix( id=matrix_id, width=shape[1], height=shape[0], - created_at=datetime.now(timezone.utc), + created_at=created_at, ) self.repo.save(matrix) return matrix_id