Skip to content

Commit a941c94

Browse files
author
Michal Tichák
committed
[coconut] fixed timestamp formatting in env list and show commands
1 parent 232d21b commit a941c94

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

coconut/control/control.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func GetEnvironments(cxt context.Context, rpc *coconut.RpcClient, cmd *cobra.Com
252252

253253
data := make([][]string, 0, 0)
254254
for _, envi := range response.GetEnvironments() {
255-
formatted := formatTimestamp(envi.GetCreatedWhen())
255+
formatted := formatTimestamp(time.Millisecond*time.Duration(envi.GetCreatedWhen()))
256256
data = append(data, []string{envi.GetId(), envi.GetRootRole(), formatted, colorState(envi.GetState())})
257257
}
258258

@@ -539,7 +539,7 @@ func ShowEnvironment(cxt context.Context, rpc *coconut.RpcClient, cmd *cobra.Com
539539
_, _ = fmt.Fprintf(o, "environment id: %s\n", env.GetId())
540540
_, _ = fmt.Fprintf(o, "workflow template: %s\n", env.GetRootRole())
541541
_, _ = fmt.Fprintf(o, "description: %s\n", env.GetDescription())
542-
_, _ = fmt.Fprintf(o, "created: %s\n", formatTimestamp(env.GetCreatedWhen()))
542+
_, _ = fmt.Fprintf(o, "created: %s\n", formatTimestamp(time.Millisecond*time.Duration(env.GetCreatedWhen())))
543543
_, _ = fmt.Fprintf(o, "state: %s\n", colorState(env.GetState()))
544544
if currentTransition := env.GetCurrentTransition(); len(currentTransition) != 0 {
545545
_, _ = fmt.Fprintf(o, "transition: %s\n", currentTransition)

coconut/control/controlutil.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ func drawTableShortTaskInfos(tasks []*pb.ShortTaskInfo, headers []string, linePr
178178
table.Render()
179179
}
180180

181-
func formatTimestamp(int64timestamp int64) string {
182-
timestamp := time.Unix(0, int64timestamp)
183-
formatted := timestamp.Local().Format("2006-01-02 15:04:05 MST")
184-
return formatted
181+
func formatTimestamp(timestamp time.Duration) string {
182+
time := time.Unix(int64(timestamp.Seconds()), 0)
183+
return time.Local().Format("2006-01-02 15:04:05 MST")
185184
}
186185

187186
func formatNumber(numberOfMachines int32) string {

0 commit comments

Comments
 (0)