Formatting time to RFC822
This commit is contained in:
parent
980bc19d10
commit
f4e891b0c1
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue