diff --git a/commands.go b/commands.go index ca3c2df606..21b2e72c28 100644 --- a/commands.go +++ b/commands.go @@ -851,7 +851,7 @@ func (cli *DockerCli) CmdHistory(args ...string) error { fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID)) } - fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) + fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0)))) if *noTrunc { fmt.Fprintf(w, "%s\t", out.CreatedBy) @@ -1208,7 +1208,7 @@ func (cli *DockerCli) CmdImages(args ...string) error { } if !*quiet { - fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t", repo, tag, out.ID, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0)))) + fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t", repo, tag, out.ID, utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0)))) if out.VirtualSize > 0 { fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.VirtualSize)) } else { @@ -1350,7 +1350,7 @@ func (cli *DockerCli) CmdPs(args ...string) error { if !*noTrunc { out.Command = utils.Trunc(out.Command, 20) } - fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", out.ID, out.Image, out.Command, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, displayablePorts(out.Ports), strings.Join(out.Names, ",")) + fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", out.ID, out.Image, out.Command, utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0))), out.Status, displayablePorts(out.Ports), strings.Join(out.Names, ",")) if *size { if out.SizeRootFs > 0 { fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.SizeRw), utils.HumanSize(out.SizeRootFs)) diff --git a/graph.go b/graph.go index b08c9cc947..0060c5246b 100644 --- a/graph.go +++ b/graph.go @@ -112,7 +112,7 @@ func (graph *Graph) Create(layerData archive.Archive, container *Container, comm img := &Image{ ID: GenerateID(), Comment: comment, - Created: time.Now(), + Created: time.Now().UTC(), DockerVersion: VERSION, Author: author, Config: config, diff --git a/image.go b/image.go index 89a78eab8b..5a0b043fc7 100644 --- a/image.go +++ b/image.go @@ -84,12 +84,12 @@ func StoreImage(img *Image, jsonData []byte, layerData archive.Archive, root, la return err } } else { - start := time.Now() + start := time.Now().UTC() utils.Debugf("Start untar layer") if err := archive.ApplyLayer(layer, layerData); err != nil { return err } - utils.Debugf("Untar time: %vs", time.Now().Sub(start).Seconds()) + utils.Debugf("Untar time: %vs", time.Now().UTC().Sub(start).Seconds()) if img.Parent == "" { if size, err = utils.TreeSize(layer); err != nil { diff --git a/runtime.go b/runtime.go index 4118e67d97..d9fe5cb4c7 100644 --- a/runtime.go +++ b/runtime.go @@ -451,7 +451,7 @@ func (runtime *Runtime) Create(config *Config, name string) (*Container, []strin container := &Container{ // FIXME: we should generate the ID here instead of receiving it as an argument ID: id, - Created: time.Now(), + Created: time.Now().UTC(), Path: entrypoint, Args: args, //FIXME: de-duplicate from config Config: config, diff --git a/server.go b/server.go index 587335b4e1..a988d2133d 100644 --- a/server.go +++ b/server.go @@ -1851,7 +1851,7 @@ func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HT } func (srv *Server) LogEvent(action, id, from string) *utils.JSONMessage { - now := time.Now().Unix() + now := time.Now().UTC().Unix() jm := utils.JSONMessage{Status: action, ID: id, From: from, Time: now} srv.AddEvent(jm) for _, c := range srv.listeners { diff --git a/state.go b/state.go index 71775719f1..1dc92af204 100644 --- a/state.go +++ b/state.go @@ -26,7 +26,7 @@ func (s *State) String() string { if s.Ghost { return fmt.Sprintf("Ghost") } - return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().Sub(s.StartedAt))) + return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) } return fmt.Sprintf("Exit %d", s.ExitCode) } @@ -67,7 +67,7 @@ func (s *State) SetRunning(pid int) { s.Ghost = false s.ExitCode = 0 s.Pid = pid - s.StartedAt = time.Now() + s.StartedAt = time.Now().UTC() } func (s *State) SetStopped(exitCode int) { @@ -76,6 +76,6 @@ func (s *State) SetStopped(exitCode int) { s.Running = false s.Pid = 0 - s.FinishedAt = time.Now() + s.FinishedAt = time.Now().UTC() s.ExitCode = exitCode } diff --git a/utils/utils.go b/utils/utils.go index a20cdc585a..892afd0c1d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -411,7 +411,7 @@ func (w *WriteBroadcaster) Write(p []byte) (n int, err error) { w.buf.Write([]byte(line)) break } - b, err := json.Marshal(&JSONLog{Log: line, Stream: sw.stream, Created: time.Now()}) + b, err := json.Marshal(&JSONLog{Log: line, Stream: sw.stream, Created: time.Now().UTC()}) if err != nil { // On error, evict the writer delete(w.writers, sw)