Skip to content

Commit

Permalink
Add timestamppb
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Aug 24, 2022
1 parent 7a7a2c3 commit dc77217
Show file tree
Hide file tree
Showing 4 changed files with 372 additions and 0 deletions.
13 changes: 13 additions & 0 deletions types/known/timestamppb/timestamp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package timestamppb

import "time"

// Now constructs a new Timestamp from the current time.
func Now() *Timestamp {
return New(time.Now())
}

// New constructs a new Timestamp from the provided time.Time.
func New(t time.Time) *Timestamp {
return &Timestamp{Seconds: int64(t.Unix()), Nanos: int32(t.Nanosecond())}
}
58 changes: 58 additions & 0 deletions types/known/timestamppb/timestamp.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions types/known/timestamppb/timestamp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// Copyright 2022 Teppei Fukuda. All rights reserved.
// https://developers.google.com/protocol-buffers/

syntax = "proto3";

package timestamppb;

option go_package = "github.com/knqyf263/go-plugin/types/known/timestamppb";

message Timestamp {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1;

// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
int32 nanos = 2;
}
278 changes: 278 additions & 0 deletions types/known/timestamppb/timestamp_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc77217

Please sign in to comment.