Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 784 Bytes

File metadata and controls

20 lines (14 loc) · 784 Bytes

Google Protos

For Elixir files generated from Google's protobuf files using protobuf-elixir.

Caution

This repo has been deprecated in favor of the main Protobuf library. To upgrade, remove :google_protos and upgrade :protobuf to v0.14+.

How-To

Convert Google.Protobuf.Timestamp to DateTime

  1. Convert timestamp seconds to nanoseconds.
  2. Add the timestamp nanos.
  3. Convert to DateTime using DateTime.from_unix!/2.
timestamp = Google.Protobuf.Timestamp.new(seconds: 5, nanos: 100)
DateTime.from_unix!(timestamp.seconds * 1_000_000_000 + timestamp.nanos, :nanosecond)