Formatting time to RFC822

This commit is contained in:
Diptanu Choudhury 2016-01-27 14:56:17 -08:00
parent 980bc19d10
commit f4e891b0c1
4 changed files with 11 additions and 3 deletions

View File

@ -220,7 +220,7 @@ func (c *AllocStatusCommand) taskStatus(alloc *api.Allocation) {
// formatUnixNanoTime is a helper for formating time for output.
func (c *AllocStatusCommand) formatUnixNanoTime(nano int64) string {
t := time.Unix(0, nano)
return t.Format("15:04:05 01/02/06")
return formatTime(t)
}
// sortedTaskStateIterator is a helper that takes the task state map and returns a

View File

@ -129,7 +129,7 @@ func (f *FSListCommand) Run(args []string) int {
out[i+1] = fmt.Sprintf("%s|%d|%s|%s",
file.FileMode,
file.Size,
file.ModTime,
formatTime(file.ModTime),
fn,
)
}

View File

@ -125,7 +125,8 @@ func (f *FSStatCommand) Run(args []string) int {
if file.IsDir {
fn = fmt.Sprintf("%s/", fn)
}
out[1] = fmt.Sprintf("%s|%d|%s|%s", file.FileMode, file.Size, file.ModTime, fn)
out[1] = fmt.Sprintf("%s|%d|%s|%s", file.FileMode, file.Size,
formatTime(file.ModTime), fn)
}
f.Ui.Output(formatList(out))
return 0

View File

@ -1,6 +1,8 @@
package command
import (
"time"
"github.com/ryanuber/columnize"
)
@ -30,3 +32,8 @@ func limit(s string, length int) string {
return s[:length]
}
// formatTime formats the time to string based on RFC822
func formatTime(t time.Time) string {
return t.Format(time.RFC822)
}