# README
timepb
timepb
is a Go package that provides functions to do time operations with
protobuf timestamp
and protobuf duration
structures.
Example
t1 := &tspb.Timestamp{Seconds: 10, Nanos: 1}
d := &durpb.Duration{Seconds: 1, Nanos: 1e9 - 1}
t2 := Add(t1, d)
fmt.Println(Compare(&tspb.Timestamp{Seconds: 12, Nanos: 0}, t2) == 0)
fmt.Println(Compare(&tspb.Timestamp{Seconds: 10, Nanos: 1}, t1) == 0)
fmt.Println(Compare(t1, t2))
// Output:
// true
// true
// -1
# Functions
Add returns a new timestamp with value t + d, where d is protobuf Duration If t is nil then nil is returned.
AddStd returns a new timestamp with value t + d, where d is stdlib Duration.
Commpare t1 and t2 and returns -1 when t1 < t2, 0 when t1 == t2 and 1 otherwise.
DurationIsNegative returns true if the duration is negative.
IsZero returns true only when t is nil.