From f0f8f613af01ee9ebe091be1122fa583e2c93bae Mon Sep 17 00:00:00 2001 From: Ioannis Mourginakis Date: Tue, 24 Oct 2023 14:55:31 -0700 Subject: [PATCH] remove miliseconds from isoformatted datetime string --- node_monitor/node_monitor_helpers/messages.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/node_monitor/node_monitor_helpers/messages.py b/node_monitor/node_monitor_helpers/messages.py index dd55a68d..09368198 100644 --- a/node_monitor/node_monitor_helpers/messages.py +++ b/node_monitor/node_monitor_helpers/messages.py @@ -6,6 +6,12 @@ # Forgive me Lord Guido, for I have broken PEP8. Principal = str +def datetime_iso8601() -> str: + """Returns the current time in ISO 8601 format, excluding milliseconds. + Example: 2021-05-01T00:00:00. + """ + return datetime.utcnow().isoformat(timespec='seconds') + def detailnode(node: ic_api.Node, label: str) -> str: """Returns: @@ -73,7 +79,7 @@ def _make_subject() -> str: f"{formatted_nodes_down}\n" f"\n" f"Node Monitor by Aviate Labs\n" - f"Report Generated: {datetime.utcnow().isoformat()} UTC\n" + f"Report Generated: {datetime_iso8601()} UTC\n" f"Help us serve you better! Provide your feedback!\n") return (subject, message) @@ -124,6 +130,6 @@ def _render_frac(numerator: int, denominator: int) -> str: f"\n" f"Thanks for reviewing today's report. We'll be back tomorrow!\n" f"Node Monitor by Aviate Labs.\n" - f"Report generated: {datetime.utcnow().isoformat()} UTC\n" + f"Report generated: {datetime_iso8601()} UTC\n" f"Help us serve you better! Provide your feedback!\n") return (subject, message)