From 39b699ad56b532e61c7309a18d2c1736ed945a19 Mon Sep 17 00:00:00 2001 From: cwasicki <126617870+cwasicki@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:31:55 +0100 Subject: [PATCH] Ensure timezone-aware timestamps in formula endpoint result Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com> --- RELEASE_NOTES.md | 1 + src/frequenz/client/reporting/_client.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e49f72e..078550d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ ## Upgrading * The CLI tool is moved to dedicated folder. +* Timestamps of aggregated (formula) requests are now timezone-aware. diff --git a/src/frequenz/client/reporting/_client.py b/src/frequenz/client/reporting/_client.py index a90ca3c..6fc686e 100644 --- a/src/frequenz/client/reporting/_client.py +++ b/src/frequenz/client/reporting/_client.py @@ -164,7 +164,9 @@ class AggregatedMetric: def sample(self) -> MetricSample: """Return the aggregated metric sample.""" return MetricSample( - timestamp=self._data_pb.sample.sampled_at.ToDatetime(), + timestamp=self._data_pb.sample.sampled_at.ToDatetime().replace( + tzinfo=timezone.utc + ), microgrid_id=self._data_pb.aggregation_config.microgrid_id, component_id=self._data_pb.aggregation_config.aggregation_formula, metric=self._data_pb.aggregation_config.metric,