Skip to content

Commit

Permalink
Merge pull request #126 from lpsinger/zulu
Browse files Browse the repository at this point in the history
Terminate timestamp with 'Z', not '+00:00'
  • Loading branch information
dakota002 authored Jul 25, 2024
2 parents 388232b + 85faeb7 commit f06a0bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gcn_classic_to_kafka/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(),
}
),
)
Expand Down

0 comments on commit f06a0bb

Please sign in to comment.