Skip to content

Commit

Permalink
Add support for TestRail timestamp type
Browse files Browse the repository at this point in the history
Convert a UNIX timestamp into a native time.Time
  • Loading branch information
gavrie committed Oct 13, 2016
1 parent 8922a30 commit 48a22e6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions timestamp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package testrail

import (
"encoding/json"
"time"
)

// UNIX timestamp
type timestamp struct {
time.Time
}

func (ts *timestamp) UnmarshalJSON(data []byte) error {
var seconds int64
if err := json.Unmarshal(data, &seconds); err != nil {
return err
}
ts.Time = time.Unix(seconds, 0)
return nil
}

0 comments on commit 48a22e6

Please sign in to comment.