Skip to content

Commit 39b699a

Browse files
committed
Ensure timezone-aware timestamps in formula endpoint result
Signed-off-by: cwasicki <[email protected]>
1 parent 9cf023f commit 39b699a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Upgrading
88

99
* The CLI tool is moved to dedicated folder.
10+
* Timestamps of aggregated (formula) requests are now timezone-aware.
1011

1112
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
1213

src/frequenz/client/reporting/_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ class AggregatedMetric:
164164
def sample(self) -> MetricSample:
165165
"""Return the aggregated metric sample."""
166166
return MetricSample(
167-
timestamp=self._data_pb.sample.sampled_at.ToDatetime(),
167+
timestamp=self._data_pb.sample.sampled_at.ToDatetime().replace(
168+
tzinfo=timezone.utc
169+
),
168170
microgrid_id=self._data_pb.aggregation_config.microgrid_id,
169171
component_id=self._data_pb.aggregation_config.aggregation_formula,
170172
metric=self._data_pb.aggregation_config.metric,

0 commit comments

Comments
 (0)