From a5805aa9227248510adbb47ef9956ba6eec9cd41 Mon Sep 17 00:00:00 2001 From: Ahmad Bamba Date: Sat, 9 Mar 2024 17:33:33 -0500 Subject: [PATCH 1/2] CR 2375: TimeType.to_readable should display microsecond precision. --- src/fprime/common/models/serialize/time_type.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fprime/common/models/serialize/time_type.py b/src/fprime/common/models/serialize/time_type.py index 53baa6a4..dfd39020 100644 --- a/src/fprime/common/models/serialize/time_type.py +++ b/src/fprime/common/models/serialize/time_type.py @@ -289,7 +289,10 @@ def to_readable(self, time_zone=None): # If we could convert to a valid datetime, use that, otherwise, format if dt: - return dt.strftime("%Y-%m-%d %H:%M:%S%z") + # datetime.isoformat() returns time string with microsecond + # precision. + # This line can be changed for other precisions or needs. + return dt.isoformat() return "%s: %d.%06ds, context=%d" % ( TimeBase(self.__timeBase.val).name, self.__secs.val, From c5728847af3c4b01db2c91858504dcb449a48641 Mon Sep 17 00:00:00 2001 From: Ahmad Bamba Date: Sun, 10 Mar 2024 00:26:22 -0500 Subject: [PATCH 2/2] CR 2375: time_type.py -- mark microseconds explicitly. Format test_type.py with Black. Add isoformat to spellcheck CI" --- .github/actions/spelling/expect.txt | 2 ++ src/fprime/common/models/serialize/time_type.py | 4 ++-- src/fprime/common/models/serialize/type_base.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index cbaf97ef..2b7a1b73 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -115,6 +115,7 @@ isdir isfile isinstance isnumeric +isoformat Isr issubclass iterdir @@ -246,6 +247,7 @@ testbuild testimpl textwrap timebase +timespec toctree todo toolchain diff --git a/src/fprime/common/models/serialize/time_type.py b/src/fprime/common/models/serialize/time_type.py index dfd39020..7dbff117 100644 --- a/src/fprime/common/models/serialize/time_type.py +++ b/src/fprime/common/models/serialize/time_type.py @@ -289,10 +289,10 @@ def to_readable(self, time_zone=None): # If we could convert to a valid datetime, use that, otherwise, format if dt: - # datetime.isoformat() returns time string with microsecond + # datetime.isoformat() returns time string with microsecond # precision. # This line can be changed for other precisions or needs. - return dt.isoformat() + return dt.isoformat(timespec="microseconds") return "%s: %d.%06ds, context=%d" % ( TimeBase(self.__timeBase.val).name, self.__secs.val, diff --git a/src/fprime/common/models/serialize/type_base.py b/src/fprime/common/models/serialize/type_base.py index ad5394cc..30861733 100644 --- a/src/fprime/common/models/serialize/type_base.py +++ b/src/fprime/common/models/serialize/type_base.py @@ -4,6 +4,7 @@ @author: reder Replaced type base class with decorators """ + import abc from .type_exceptions import AbstractMethodException