Skip to content

Commit

Permalink
[sc-212190] fix: archived date always parsing as today (#47)
Browse files Browse the repository at this point in the history
template date function needs `time.Time` not unix timestamp
  • Loading branch information
jazanne authored Aug 9, 2023
1 parent 4a5ee7f commit f41a183
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion comments/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"reflect"
"sort"
"strings"
"time"

sprig "github.com/Masterminds/sprig/v3"

Expand All @@ -23,6 +24,7 @@ import (

type Comment struct {
Flag ldapi.FeatureFlag
ArchivedAt time.Time
Added bool
Aliases []string
ChangeType string
Expand All @@ -44,11 +46,14 @@ func githubFlagComment(flag ldapi.FeatureFlag, aliases []string, added bool, con
LDInstance: config.LdInstance,
}
var commentBody bytes.Buffer
if flag.ArchivedDate != nil {
commentTemplate.ArchivedAt = time.UnixMilli(*flag.ArchivedDate)
}
// All whitespace for template is required to be there or it will not render properly nested.
tmplSetup := `| {{- if eq .Flag.Archived true}}{{- if eq .Added true}} :warning:{{- end}}{{- end}}` +
` [{{.Flag.Name}}]({{.LDInstance}}{{.Primary.Site.Href}})` +
`{{- if eq .Flag.Archived true}}` +
` (archived on {{.Flag.ArchivedDate | date "2006-01-02"}})` +
` (archived on {{.ArchivedAt | date "2006-01-02"}})` +
`{{- end}} | ` +
"`" + `{{.Flag.Key}}` + "` |" +
`{{- if ne (len .Aliases) 0}}` +
Expand Down

0 comments on commit f41a183

Please sign in to comment.