Skip to content

Commit 745a41a

Browse files
Fix timestamp typing (#360)
Ref: #359 (comment)
1 parent 9df411b commit 745a41a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

protovalidate/internal/rules.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import celpy
2121
from celpy import celtypes
22-
from google.protobuf import any_pb2, descriptor, duration_pb2, message, message_factory
22+
from google.protobuf import any_pb2, descriptor, duration_pb2, message, message_factory, timestamp_pb2
2323

2424
from buf.validate import validate_pb2
2525
from protovalidate.config import Config
@@ -37,8 +37,10 @@ def make_duration(msg: duration_pb2.Duration) -> celtypes.DurationType:
3737
)
3838

3939

40-
def make_timestamp(msg: duration_pb2.Duration) -> celtypes.TimestampType:
41-
return celtypes.TimestampType(1970, 1, 1) + make_duration(msg)
40+
def make_timestamp(msg: timestamp_pb2.Timestamp) -> celtypes.TimestampType:
41+
return celtypes.TimestampType(1970, 1, 1) + make_duration(
42+
duration_pb2.Duration(seconds=msg.seconds, nanos=msg.nanos)
43+
)
4244

4345

4446
def unwrap(msg: message.Message) -> celtypes.Value:

0 commit comments

Comments
 (0)