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},
|
{"Filename", resp.Filename},
|
||||||
{"Filesize", resp.Filesize},
|
{"Filesize", resp.Filesize},
|
||||||
{"Categories", strings.Join(resp.Categories.Names(), "\n")},
|
{"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.SetOutputMirror(os.Stdout)
|
||||||
t.SetStyle(table.StyleLight)
|
t.SetStyle(table.StyleLight)
|
||||||
|
@ -16,15 +16,18 @@ type Tag struct {
|
|||||||
ImageUrl string `json:"page_url"`
|
ImageUrl string `json:"page_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Tags) NamesWithAgeAt(createdAt TimeResult) []string {
|
func (t Tags) NamesWithAgeAt(createdAt *TimeResult) []string {
|
||||||
names := make([]string, len(c))
|
names := make([]string, len(t))
|
||||||
for i, category := range c {
|
for i, tag := range t {
|
||||||
bd := category.Birthdate.AgeAt(createdAt)
|
names[i] = tag.NameWithAgeAt(createdAt)
|
||||||
if bd != "" {
|
|
||||||
names[i] = fmt.Sprintf("%s (%s)", category.Name, bd)
|
|
||||||
} else {
|
|
||||||
names[i] = category.Name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return names
|
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)
|
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
|
var year, month, day, hour, min, sec int
|
||||||
a := c.toTime()
|
a := c.toTime()
|
||||||
if a.IsZero() {
|
if a.IsZero() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user