File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ name = "saluki"
77dynamic = [" version" ]
88dependencies = [
99 " ess-streaming-data-types" ,
10- " confluent-kafka"
10+ " confluent-kafka" ,
11+ " tzdata"
1112]
1213readme = {file = " README.md" , content-type = " text/markdown" }
1314license-files = [" LICENSE" ]
Original file line number Diff line number Diff line change 11import datetime
22import logging
33from typing import List , Tuple
4+ from zoneinfo import ZoneInfo
45
56from confluent_kafka import Message
67from streaming_data_types import DESERIALISERS
@@ -66,8 +67,10 @@ def _parse_timestamp(msg: Message) -> str:
6667 """
6768 timestamp_type , timestamp_ms_from_epoch = msg .timestamp ()
6869 if timestamp_type == 1 : # TIMESTAMP_CREATE_TIME
69- return datetime .datetime .fromtimestamp (timestamp_ms_from_epoch / 1000 ).strftime (
70- "%Y-%m-%d %H:%M:%S.%f"
70+ return (
71+ datetime .datetime .fromtimestamp (timestamp_ms_from_epoch / 1000 )
72+ .astimezone (ZoneInfo ("UTC" ))
73+ .strftime ("%Y-%m-%d %H:%M:%S.%f" )
7174 )
7275 else :
7376 # TIMESTAMP_NOT_AVAILABLE or TIMESTAMP_LOG_APPEND_TIME
Original file line number Diff line number Diff line change @@ -64,11 +64,11 @@ def test_deserialising_message_which_raises_does_not_stop_loop(mock_message):
6464 ok_message = Mock (spec = Message )
6565 ok_message .value .return_value = b""
6666 ok_message .error .return_value = False
67- ok_message .timestamp .return_value = 1 , 1
67+ ok_message .timestamp .return_value = 2 , 1
6868
6969 mock_message .value .side_effect = Exception
7070 mock_message .error .return_value = False
71- mock_message .timestamp .return_value = 1 , 1
71+ mock_message .timestamp .return_value = 2 , 1
7272
7373 _deserialise_and_print_messages ([mock_message , ok_message ], None )
7474 assert logger .info .call_count == 1
@@ -125,7 +125,7 @@ def test_message_that_has_valid_schema_and_valid_payload(mock_message):
125125
126126def test_parse_timestamp_with_valid_timestamp (mock_message ):
127127 mock_message .timestamp .return_value = (1 , 1753434939336 )
128- assert _parse_timestamp (mock_message ) == "2025-07-25 10 :15:39.336000"
128+ assert _parse_timestamp (mock_message ) == "2025-07-25 09 :15:39.336000"
129129
130130
131131def test_parse_timestamp_with_timestamp_not_available (mock_message ):
You can’t perform that action at this time.
0 commit comments