| Index: go/buildbucket/buildbucket.go
|
| diff --git a/go/buildbucket/buildbucket.go b/go/buildbucket/buildbucket.go
|
| index 050d767fa1bceb8850b245b1454e9b92ac12f6be..76595456be8456c43c7d4857166719af1f82daca 100644
|
| --- a/go/buildbucket/buildbucket.go
|
| +++ b/go/buildbucket/buildbucket.go
|
| @@ -7,6 +7,8 @@ import (
|
| "fmt"
|
| "io/ioutil"
|
| "net/http"
|
| + "strconv"
|
| + "time"
|
|
|
| "go.skia.org/infra/go/util"
|
| )
|
| @@ -67,6 +69,49 @@ type Build struct {
|
| UtcNowTimestamp string `json:"utcnow_ts"`
|
| }
|
|
|
| +func (b *Build) Copy() *Build {
|
| + return &Build{
|
| + Bucket: b.Bucket,
|
| + CompletedTimestamp: b.CompletedTimestamp,
|
| + CreatedBy: b.CreatedBy,
|
| + CreatedTimestamp: b.CreatedTimestamp,
|
| + FailureReason: b.FailureReason,
|
| + Id: b.Id,
|
| + Url: b.Url,
|
| + ParametersJson: b.ParametersJson,
|
| + Result: b.Result,
|
| + ResultDetailsJson: b.ResultDetailsJson,
|
| + Status: b.Status,
|
| + StatusChangedTimestamp: b.StatusChangedTimestamp,
|
| + UpdatedTimestamp: b.UpdatedTimestamp,
|
| + UtcNowTimestamp: b.UtcNowTimestamp,
|
| + }
|
| +}
|
| +
|
| +func parseTime(t string) (time.Time, error) {
|
| + i, err := strconv.ParseInt(t, 10, 64)
|
| + if err != nil {
|
| + return time.Time{}, err
|
| + }
|
| + return time.Unix(0, i), nil
|
| +}
|
| +
|
| +func (b *Build) Created() (time.Time, error) {
|
| + return parseTime(b.CreatedTimestamp)
|
| +}
|
| +
|
| +func (b *Build) Completed() (time.Time, error) {
|
| + return parseTime(b.CompletedTimestamp)
|
| +}
|
| +
|
| +func (b *Build) StatusChanged() (time.Time, error) {
|
| + return parseTime(b.StatusChangedTimestamp)
|
| +}
|
| +
|
| +func (b *Build) Updated() (time.Time, error) {
|
| + return parseTime(b.UpdatedTimestamp)
|
| +}
|
| +
|
| // Client is used for interacting with the BuildBucket API.
|
| type Client struct {
|
| *http.Client
|
|
|