ProtoBuf.jl
ProtoBuf.jl copied to clipboard
Julia Dates.DateTime type
Just a quick query about the DateTime type in Julia.
If one wanted to serialize this using Protobuf, what might be the best way of approaching this?
I tried serializing to integer UInt64.
julia> dt = DateTime(2025,4,22)
2025-04-22T00:00:00
julia> convert(UInt64, dt)
ERROR: MethodError: Cannot `convert` an object of type DateTime to an object of type UInt64
According to this question on Stack Overflow, there is a Datetime type.
import "google/protobuf/timestamp.proto";
```
I tried this too. I get a different error
```
julia> Example.MyMessage(DateTime(2025))
ERROR: MethodError: Cannot `convert` an object of type DateTime to an object of type Main.BidAskTimeseries_pb.google.protobuf.Timestamp
```
The corresponding proto file:
```
syntax = "proto3";
import "google/protobuf/timestamp.proto";
message MyMessage {
google.protobuf.Timestamp timestamp = 1;
}
```