From 85faeb79ac17cdeff6f7b438b889f7db952c0aeb Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Thu, 25 Jul 2024 11:55:03 -0400 Subject: [PATCH] Terminate timestamp with 'Z', not '+00:00' --- gcn_classic_to_kafka/heartbeat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcn_classic_to_kafka/heartbeat.py b/gcn_classic_to_kafka/heartbeat.py index df2c544..31d9de7 100644 --- a/gcn_classic_to_kafka/heartbeat.py +++ b/gcn_classic_to_kafka/heartbeat.py @@ -18,6 +18,11 @@ TOPIC = "gcn.heartbeat" +def iso8601_now(): + """Return the current time as an ISO 8601 string, ending in 'Z'.""" + return datetime.datetime.now(datetime.UTC).isoformat().split("+")[0] + "Z" + + async def run(producer: confluent_kafka.Producer): """Produce a heartbeat message once per second.""" log.info("Producing heartbeats every %d second(s) on topic %s", TIMEOUT, TOPIC) @@ -27,7 +32,7 @@ async def run(producer: confluent_kafka.Producer): json.dumps( { "$schema": "https://gcn.nasa.gov/docs/schema/v4.1.0/gcn/notices/core/Alert.schema.json", - "alert_datetime": datetime.datetime.now(datetime.UTC).isoformat(), + "alert_datetime": iso8601_now(), } ), )