Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions github/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func (t Timestamp) String() string {
return t.Time.String()
}

// GetTime returns std time.Time
func (t *Timestamp) GetTime() *time.Time {
if t == nil {
return nil
}
return &t.Time
}

// UnmarshalJSON implements the json.Unmarshaler interface.
// Time is expected in RFC3339 or Unix format.
func (t *Timestamp) UnmarshalJSON(data []byte) (err error) {
Expand Down
11 changes: 11 additions & 0 deletions github/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ func TestWrappedTimestamp_Unmarshal(t *testing.T) {
}
}

func TestTimestamp_GetTime(t *testing.T) {
var t1 *Timestamp
if t1.GetTime() != nil {
t.Errorf("nil timestamp should return nil, got: %v", t1.GetTime())
}
t1 = &Timestamp{referenceTime}
if !t1.GetTime().Equal(referenceTime) {
t.Errorf("want reference time, got: %s", t1.GetTime().String())
}
}

func TestWrappedTimestamp_MarshalReflexivity(t *testing.T) {
testCases := []struct {
desc string
Expand Down