mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 02:02:37 +02:00
pointer to timeresult
This commit is contained in:
parent
9190f23188
commit
1e948b887e
@ -58,7 +58,7 @@ func (c *ImageDetailsCommand) Execute(args []string) error {
|
||||
{"Filename", resp.Filename},
|
||||
{"Filesize", resp.Filesize},
|
||||
{"Categories", strings.Join(resp.Categories.Names(), "\n")},
|
||||
{"Tags", strings.Join(resp.Tags.NamesWithAgeAt(resp.DateCreation), "\n")},
|
||||
{"Tags", strings.Join(resp.Tags.NamesWithAgeAt(&resp.DateCreation), "\n")},
|
||||
})
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
t.SetStyle(table.StyleLight)
|
||||
|
@ -16,15 +16,18 @@ type Tag struct {
|
||||
ImageUrl string `json:"page_url"`
|
||||
}
|
||||
|
||||
func (c Tags) NamesWithAgeAt(createdAt TimeResult) []string {
|
||||
names := make([]string, len(c))
|
||||
for i, category := range c {
|
||||
bd := category.Birthdate.AgeAt(createdAt)
|
||||
if bd != "" {
|
||||
names[i] = fmt.Sprintf("%s (%s)", category.Name, bd)
|
||||
} else {
|
||||
names[i] = category.Name
|
||||
}
|
||||
func (t Tags) NamesWithAgeAt(createdAt *TimeResult) []string {
|
||||
names := make([]string, len(t))
|
||||
for i, tag := range t {
|
||||
names[i] = tag.NameWithAgeAt(createdAt)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
func (t *Tag) NameWithAgeAt(createdAt *TimeResult) string {
|
||||
bd := t.Birthdate.AgeAt(createdAt)
|
||||
if bd != "" {
|
||||
return fmt.Sprintf("%s (%s)", t.Name, bd)
|
||||
}
|
||||
return t.Name
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (c TimeResult) toTime() time.Time {
|
||||
return time.Time(c)
|
||||
}
|
||||
|
||||
func (c TimeResult) AgeAt(createdAt TimeResult) string {
|
||||
func (c TimeResult) AgeAt(createdAt *TimeResult) string {
|
||||
var year, month, day, hour, min, sec int
|
||||
a := c.toTime()
|
||||
if a.IsZero() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user