Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 879302e

Browse files
author
Vincent Demeester
authored
Merge pull request #223 from chris-crone/version-time
Format version time as in docker/cli
2 parents 2ae9d25 + 3cff8f2 commit 879302e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

internal/version.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"runtime"
66
"strings"
7+
"time"
78
)
89

910
var (
@@ -20,10 +21,19 @@ func FullVersion() string {
2021
res := []string{
2122
fmt.Sprintf("Version: %s", Version),
2223
fmt.Sprintf("Git commit: %s", GitCommit),
23-
fmt.Sprintf("Build time: %s", BuildTime),
24+
fmt.Sprintf("Built: %s", reformatDate(BuildTime)),
2425
fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH),
2526
fmt.Sprintf("Experimental: %s", Experimental),
2627
fmt.Sprintf("Renderers: %s", Renderers),
2728
}
2829
return strings.Join(res, "\n")
2930
}
31+
32+
// FIXME(chris-crone): use function in docker/cli/cli/command/system/version.go.
33+
func reformatDate(buildTime string) string {
34+
t, errTime := time.Parse(time.RFC3339Nano, buildTime)
35+
if errTime == nil {
36+
return t.Format(time.ANSIC)
37+
}
38+
return buildTime
39+
}

0 commit comments

Comments
 (0)