Skip to content

Commit

Permalink
fix(matrix-service): do not use the timezone.utc timezone to preser…
Browse files Browse the repository at this point in the history
…ve a naive datetime
  • Loading branch information
laurent-laporte-pro committed Nov 11, 2023
1 parent 26574de commit 688842a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions antarest/matrixstore/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 688842a

Please sign in to comment.