Using Dates and Times in Protobuf
Learn how to use timestamps and durations in Protobuf.
We'll cover the following
Any programming language can work with dates and times. Protobuf can do it too with the help of one of its built-in packages. Dates and times can be handled by the Timestamp
type and durations can be handled by the Duration
type. These are roughly equivalent to the DateTime
and TimeSpan
types from C#.
In this lesson, we'll learn how to use both data types. We'll learn how to read and write into a Timespan
field from C# code. We'll also learn how to use the Duration
type as the difference between two Timestamp
values.
Enabling Timestamp
and Duration
in Protobuf
The following code widget contains the code that we'll be making our changes to. This represents the complete setup we've built previously.
Get hands-on with 1200+ tech skills courses.