I want to map datetime in c# datetime in protobuf . Do you have any suggestion to do this?
Asked
Active
Viewed 6,945 times
7
-
1Did you try to reach the documentation? – Pavel Anikhouski Sep 15 '20 at 10:12
-
Yes but I didn't reach a conclusion, Do you any resources about it ? – Mohadese Entezari Sep 15 '20 at 10:20
-
Can you post the links to the documentation you have read and also add some code lines on the conversion, this way others can help you check for issues. – Pimenta Sep 15 '20 at 11:18
1 Answers
8
If you mean the Google implementation: quite simply, FromDateTime
and ToDateTime
Google.Protobuf.WellKnownTypes.Timestamp protoTimestamp
= Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.Now);
(I add that qualification because protobuf-net also defines similarly named types, which have implicit conversion operators to/from DateTime
)

Jeff Maass
- 3,632
- 3
- 26
- 30

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900