6

I am trying to write some code that will generate accurate .proto files from the protobuf-net (V2) runtime type model, so I can write a python client capable of deserializing protobuf-net generated messages.

I am a little bit stuck on what the messages should look like for datetime though, can anyone shed some light on this?

Thanks <3

Franchesca
  • 1,453
  • 17
  • 32

1 Answers1

8

The core protobuf spec has no inbuilt mechanism for handling dates/times.

If you are working between platforms, then frankly I would suggest exposing it in a more simpler manner, such as a long (unix time, or similar). protobuf-net uses a bit of a more granular layout, to exploit the fact that many many datetime values are pure dates, etc. There was a BCL.proto on the project site, but I can't seem to find it right now... that is odd (I will investigate). However: if the option is available: just expose the data in a simpler manner.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Unfortunately I don't have control over the .NET types that will be sent and received. If someone sends a .NET DateTime object over the wire to my python client, I need to know exactly how protobuf-net serialized it (the exact message definition) so I can deserialize it. – Franchesca Jun 14 '12 at 08:42
  • I found a copy of bcl.proto [here](http://code.google.com/p/protobuf-net/source/browse/trunk/Tools/bcl.proto?r=282). Is this applicable to v2? – Franchesca Jun 14 '12 at 12:21
  • @Franchesca well, the format is identical between v1 and v2. I do emphasise, though, that `DateTime` support is not part of the core spec, and is primarily intended for .NET-to-.NET usage; it would be much easier to use unix time... – Marc Gravell Jun 14 '12 at 12:55
  • Great, thanks for your help! (I know you are right, but I'm afraid my python client will have to make do with sharing it's older .NET brother's types, even if they fit a little strangely and the other python children laugh at him. :P) – Franchesca Jun 14 '12 at 15:45