diff options
author | Michael Muré <batolettre@gmail.com> | 2020-06-25 23:18:17 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-06-25 23:18:17 +0200 |
commit | aab3a04d0c4ddbf97d589ba9048a539c6d7186e9 (patch) | |
tree | 5db59215d2c9559c2d33d1a2a2010270a88d669d /commands/ls.go | |
parent | 1d06244c82b18959878cf199cd8dd500bbc46aa7 (diff) | |
download | git-bug-aab3a04d0c4ddbf97d589ba9048a539c6d7186e9.tar.gz |
bug: harmonize how time are used, fix some issues in command special formats
This assume that the convertion from time.Time <--> Unix timestamp is lossless which seems to be.
Diffstat (limited to 'commands/ls.go')
-rw-r--r-- | commands/ls.go | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/commands/ls.go b/commands/ls.go index e1a7166a..34f1f982 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "strings" - "time" text "github.com/MichaelMure/go-term-text" "github.com/spf13/cobra" @@ -75,10 +74,10 @@ func runLsBug(_ *cobra.Command, args []string) error { } type JSONBugExcerpt struct { - Id string `json:"id"` - HumanId string `json:"human_id"` - CreationTime time.Time `json:"creation_time"` - LastEdited time.Time `json:"last_edited"` + Id string `json:"id"` + HumanId string `json:"human_id"` + CreateTime JSONTime `json:"create_time"` + EditTime JSONTime `json:"edit_time"` Status string `json:"status"` Labels []bug.Label `json:"labels"` @@ -95,15 +94,15 @@ func lsJsonFormatter(backend *cache.RepoCache, bugExcerpts []*cache.BugExcerpt) jsonBugs := make([]JSONBugExcerpt, len(bugExcerpts)) for i, b := range bugExcerpts { jsonBug := JSONBugExcerpt{ - Id: b.Id.String(), - HumanId: b.Id.Human(), - CreationTime: time.Unix(b.CreateUnixTime, 0), - LastEdited: time.Unix(b.EditUnixTime, 0), - Status: b.Status.String(), - Labels: b.Labels, - Title: b.Title, - Comments: b.LenComments, - Metadata: b.CreateMetadata, + Id: b.Id.String(), + HumanId: b.Id.Human(), + CreateTime: NewJSONTime(b.CreateTime(), b.CreateLamportTime), + EditTime: NewJSONTime(b.EditTime(), b.EditLamportTime), + Status: b.Status.String(), + Labels: b.Labels, + Title: b.Title, + Comments: b.LenComments, + Metadata: b.CreateMetadata, } if b.AuthorId != "" { @@ -225,15 +224,13 @@ func lsOrgmodeFormatter(backend *cache.RepoCache, bugExcerpts []*cache.BugExcerp fmt.Printf("* %s %s [%s] %s: %s %s\n", b.Id.Human(), status, - time.Unix(b.CreateUnixTime, 0), + b.CreateTime(), name, title, labelsString, ) - fmt.Printf("** Last Edited: %s\n", - time.Unix(b.EditUnixTime, 0).String(), - ) + fmt.Printf("** Last Edited: %s\n", b.EditTime().String()) fmt.Printf("** Actors:\n") for _, element := range b.Actors { |