Aditya Sanghi Aditya Sanghi - 4 years ago 233
Ruby Question

How can we convert google.protobuf.Timestamp to Ruby DateTime object?

There aren't much of details for this question, I am getting a kafka event where the time is of type

. These kafka events are being posted(through HTTP) to my rails app where I need the time to be in datetime format of ruby instead of

Answer Source

Convert microseconds to nanos and use, microseconds_with_frac) → time

epoch_micros = timestamp.nanos / 10 ** 6, epoch_micros)

for reference:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download