From 71da2e1d753ee66fe6ffb4670b173a38145e97d0 Mon Sep 17 00:00:00 2001 From: Daniel Hatton Date: Mon, 9 Sep 2024 15:23:59 +0100 Subject: [PATCH] Use a datetime object for file timestamps rather than float (#340) --- src/murfey/instrument_server/api.py | 3 ++- src/murfey/util/models.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/murfey/instrument_server/api.py b/src/murfey/instrument_server/api.py index 849ae21b..ea275cf5 100644 --- a/src/murfey/instrument_server/api.py +++ b/src/murfey/instrument_server/api.py @@ -1,5 +1,6 @@ import secrets import time +from datetime import datetime from logging import getLogger from pathlib import Path from typing import Annotated, Dict, List, Optional, Union @@ -220,7 +221,7 @@ def get_possible_gain_references() -> List[File]: name=gf.name, description="", size=gf.stat().st_size / 1e6, - timestamp=gf.stat().st_mtime, + timestamp=datetime.fromtimestamp(gf.stat().st_mtime), full_path=str(gf), ) ) diff --git a/src/murfey/util/models.py b/src/murfey/util/models.py index e2eab7a0..192cb9e2 100644 --- a/src/murfey/util/models.py +++ b/src/murfey/util/models.py @@ -85,7 +85,8 @@ class File(BaseModel): name: str description: str size: int - timestamp: float + timestamp: datetime + full_path: str class ConnectionFileParameters(BaseModel):