diff --git a/main.go b/main.go index 67ce57e..c3a0d10 100644 --- a/main.go +++ b/main.go @@ -203,7 +203,10 @@ func printCharacterSkillQueue(swaggerclient *ESI.App, m *Character) { name := skillNames[*skill.SkillID] finishDate := time.Time(skill.FinishDate) - duration := finishDate.Sub(now) + startDate := time.Time(skill.StartDate) + + skillDuration := finishDate.Sub(startDate) + finishDuration := finishDate.Sub(now) maxSkillFormat := fmt.Sprintf("%d", maxSkillLength) @@ -211,28 +214,29 @@ func printCharacterSkillQueue(swaggerclient *ESI.App, m *Character) { // The queue is only updated when the user logs in with the client // we thus need to do the computations and filtering ourselves if finishDate.Before(time.Now()) { - fmt.Printf("✔ % "+maxSkillFormat+"s - L%d\n", + fmt.Printf("✔ %"+maxSkillFormat+"s %d\n", name, *skill.FinishedLevel, ) continue } - fmt.Printf(" % "+maxSkillFormat+"s - L%d - ends on %s (%s)\n", + fmt.Printf(" %"+maxSkillFormat+"s %d, %s - ends on %s (%s)\n", name, *skill.FinishedLevel, + formatDuration(skillDuration, 2), time.Time(skill.FinishDate).Format(defaultDateFormat), - formatDuration(duration), + formatDuration(finishDuration, 3), ) } } -func formatDuration(duration time.Duration) string { +func formatDuration(duration time.Duration, daysLength int32) string { days := int32(duration.Hours()) / 24 hours := int32(duration.Minutes()) / 60 % 24 minutes := int32(duration.Minutes()) % 60 - return fmt.Sprintf("% 4dd %02d:%02d", days, hours, minutes) + return fmt.Sprintf("%"+fmt.Sprintf("%d", daysLength)+"dd %02d:%02d", days, hours, minutes) } func printCharacterInformation(swaggerclient *ESI.App, m *Character) { @@ -376,14 +380,14 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) { duration = time.Time(pin.ExpiryTime).Sub(now) } - fmt.Printf(" %s Extractor % 5ds cycle, %s, %d per cycle, %s %s (%s)\n", + fmt.Printf(" %s Extractor %4ds cycle, %s, %d per cycle, %s %s (%s)\n", status, *pin.ExtractorDetails.CycleTime, pinNames[*pin.ExtractorDetails.ProductTypeID], *pin.ExtractorDetails.QtyPerCycle, statuscomment, time.Time(pin.ExpiryTime).Format(defaultDateFormat), - formatDuration(duration), + formatDuration(duration, 2), ) } else if pin.SchematicID != 0 { @@ -393,7 +397,7 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) { log.Printf("Error on getSchematicsInformation: %T, %s\n", serr, serr) fmt.Printf(" ✔ Factory ????? cycle, ?????\n") } else { - fmt.Printf(" ✔ Factory % 5ds cycle, %s\n", + fmt.Printf(" ✔ Factory %4ds cycle, %s\n", schematicInfo.CycleTime, schematicInfo.SchematicName, )