File tree 2 files changed +19
-0
lines changed 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ func (t Timestamp) String() string {
22
22
return t .Time .String ()
23
23
}
24
24
25
+ // GetTime returns std time.Time.
26
+ func (t * Timestamp ) GetTime () * time.Time {
27
+ if t == nil {
28
+ return nil
29
+ }
30
+ return & t .Time
31
+ }
32
+
25
33
// UnmarshalJSON implements the json.Unmarshaler interface.
26
34
// Time is expected in RFC3339 or Unix format.
27
35
func (t * Timestamp ) UnmarshalJSON (data []byte ) (err error ) {
Original file line number Diff line number Diff line change @@ -169,6 +169,17 @@ func TestWrappedTimestamp_Unmarshal(t *testing.T) {
169
169
}
170
170
}
171
171
172
+ func TestTimestamp_GetTime (t * testing.T ) {
173
+ var t1 * Timestamp
174
+ if t1 .GetTime () != nil {
175
+ t .Errorf ("nil timestamp should return nil, got: %v" , t1 .GetTime ())
176
+ }
177
+ t1 = & Timestamp {referenceTime }
178
+ if ! t1 .GetTime ().Equal (referenceTime ) {
179
+ t .Errorf ("want reference time, got: %s" , t1 .GetTime ().String ())
180
+ }
181
+ }
182
+
172
183
func TestWrappedTimestamp_MarshalReflexivity (t * testing.T ) {
173
184
testCases := []struct {
174
185
desc string
You can’t perform that action at this time.
0 commit comments