1
1
from datetime import datetime
2
2
from typing import Optional , List , Union , Dict
3
- from hiero_sdk_python .hapi .mirror import consensus_service_pb2 as mirror_proto
4
3
5
- def _to_datetime (ts_proto ) -> datetime :
6
- """
7
- Convert a protobuf Timestamp to a Python datetime (UTC).
8
- """
9
- return datetime .utcfromtimestamp (ts_proto .seconds + ts_proto .nanos / 1e9 )
4
+ from hiero_sdk_python import Timestamp
5
+ from hiero_sdk_python .hapi .mirror import consensus_service_pb2 as mirror_proto
10
6
11
7
12
8
class TopicMessageChunk :
@@ -16,7 +12,7 @@ class TopicMessageChunk:
16
12
"""
17
13
18
14
def __init__ (self , response : mirror_proto .ConsensusTopicResponse ):
19
- self .consensus_timestamp = _to_datetime (response .consensusTimestamp )
15
+ self .consensus_timestamp = Timestamp . from_protobuf (response .consensusTimestamp ). to_date ( )
20
16
self .content_size = len (response .message )
21
17
self .running_hash = response .runningHash
22
18
self .sequence_number = response .sequenceNumber
@@ -118,7 +114,7 @@ def of_many(cls, responses: List[mirror_proto.ConsensusTopicResponse]) -> "Topic
118
114
offset = end
119
115
120
116
last_r = sorted_responses [- 1 ]
121
- consensus_timestamp = _to_datetime (last_r .consensusTimestamp )
117
+ consensus_timestamp = Timestamp . from_protobuf (last_r .consensusTimestamp ). to_date ( )
122
118
running_hash = last_r .runningHash
123
119
sequence_number = last_r .sequenceNumber
124
120
0 commit comments