From 806abe90ba38741707f58e98ecdcdd4bc19f52e2 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Thu, 21 Nov 2013 16:41:41 -0800 Subject: [PATCH] Use UTC for time --- commands.go | 6 +++--- graph.go | 2 +- image.go | 4 ++-- runtime.go | 2 +- server.go | 2 +- state.go | 6 +++--- utils/utils.go | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/commands.go b/commands.go index c514aa28a0..cf9ce3308a 100644 --- a/commands.go +++ b/commands.go @@ -847,7 +847,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) @@ -1202,7 +1202,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 { @@ -1344,7 +1344,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 062cf7be20..d19e7eec54 100644 --- a/graph.go +++ b/graph.go @@ -99,7 +99,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 7ba4da3158..0b3e66670e 100644 --- a/image.go +++ b/image.go @@ -89,12 +89,12 @@ func StoreImage(img *Image, jsonData []byte, layerData archive.Archive, root str // If layerData is not nil, unpack it into the new layer if layerData != nil { - start := time.Now() + start := time.Now().UTC() utils.Debugf("Start untar layer") if err := archive.Untar(layerData, layer); 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 raw json is provided, then use it diff --git a/runtime.go b/runtime.go index 3c90616f16..01c47d5234 100644 --- a/runtime.go +++ b/runtime.go @@ -421,7 +421,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 a65a839428..a0454e678a 100644 --- a/server.go +++ b/server.go @@ -1838,7 +1838,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.events = append(srv.events, 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 5864add8e1..bfae26a92d 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)