Browse code

Use UTC for time

Guillaume J. Charmes authored on 2013/11/22 09:41:41
Showing 7 changed files
... ...
@@ -847,7 +847,7 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
847 847
 				fmt.Fprintf(w, "%s\t", utils.TruncateID(out.ID))
848 848
 			}
849 849
 
850
-			fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))))
850
+			fmt.Fprintf(w, "%s ago\t", utils.HumanDuration(time.Now().UTC().Sub(time.Unix(out.Created, 0))))
851 851
 
852 852
 			if *noTrunc {
853 853
 				fmt.Fprintf(w, "%s\t", out.CreatedBy)
... ...
@@ -1202,7 +1202,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
1202 1202
 				}
1203 1203
 
1204 1204
 				if !*quiet {
1205
-					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))))
1205
+					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))))
1206 1206
 					if out.VirtualSize > 0 {
1207 1207
 						fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.Size), utils.HumanSize(out.VirtualSize))
1208 1208
 					} else {
... ...
@@ -1344,7 +1344,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
1344 1344
 			if !*noTrunc {
1345 1345
 				out.Command = utils.Trunc(out.Command, 20)
1346 1346
 			}
1347
-			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, ","))
1347
+			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, ","))
1348 1348
 			if *size {
1349 1349
 				if out.SizeRootFs > 0 {
1350 1350
 					fmt.Fprintf(w, "%s (virtual %s)\n", utils.HumanSize(out.SizeRw), utils.HumanSize(out.SizeRootFs))
... ...
@@ -99,7 +99,7 @@ func (graph *Graph) Create(layerData archive.Archive, container *Container, comm
99 99
 	img := &Image{
100 100
 		ID:            GenerateID(),
101 101
 		Comment:       comment,
102
-		Created:       time.Now(),
102
+		Created:       time.Now().UTC(),
103 103
 		DockerVersion: VERSION,
104 104
 		Author:        author,
105 105
 		Config:        config,
... ...
@@ -89,12 +89,12 @@ func StoreImage(img *Image, jsonData []byte, layerData archive.Archive, root str
89 89
 
90 90
 	// If layerData is not nil, unpack it into the new layer
91 91
 	if layerData != nil {
92
-		start := time.Now()
92
+		start := time.Now().UTC()
93 93
 		utils.Debugf("Start untar layer")
94 94
 		if err := archive.Untar(layerData, layer); err != nil {
95 95
 			return err
96 96
 		}
97
-		utils.Debugf("Untar time: %vs", time.Now().Sub(start).Seconds())
97
+		utils.Debugf("Untar time: %vs", time.Now().UTC().Sub(start).Seconds())
98 98
 	}
99 99
 
100 100
 	// If raw json is provided, then use it
... ...
@@ -421,7 +421,7 @@ func (runtime *Runtime) Create(config *Config, name string) (*Container, []strin
421 421
 	container := &Container{
422 422
 		// FIXME: we should generate the ID here instead of receiving it as an argument
423 423
 		ID:              id,
424
-		Created:         time.Now(),
424
+		Created:         time.Now().UTC(),
425 425
 		Path:            entrypoint,
426 426
 		Args:            args, //FIXME: de-duplicate from config
427 427
 		Config:          config,
... ...
@@ -1838,7 +1838,7 @@ func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HT
1838 1838
 }
1839 1839
 
1840 1840
 func (srv *Server) LogEvent(action, id, from string) *utils.JSONMessage {
1841
-	now := time.Now().Unix()
1841
+	now := time.Now().UTC().Unix()
1842 1842
 	jm := utils.JSONMessage{Status: action, ID: id, From: from, Time: now}
1843 1843
 	srv.events = append(srv.events, jm)
1844 1844
 	for _, c := range srv.listeners {
... ...
@@ -26,7 +26,7 @@ func (s *State) String() string {
26 26
 		if s.Ghost {
27 27
 			return fmt.Sprintf("Ghost")
28 28
 		}
29
-		return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().Sub(s.StartedAt)))
29
+		return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
30 30
 	}
31 31
 	return fmt.Sprintf("Exit %d", s.ExitCode)
32 32
 }
... ...
@@ -67,7 +67,7 @@ func (s *State) SetRunning(pid int) {
67 67
 	s.Ghost = false
68 68
 	s.ExitCode = 0
69 69
 	s.Pid = pid
70
-	s.StartedAt = time.Now()
70
+	s.StartedAt = time.Now().UTC()
71 71
 }
72 72
 
73 73
 func (s *State) SetStopped(exitCode int) {
... ...
@@ -76,6 +76,6 @@ func (s *State) SetStopped(exitCode int) {
76 76
 
77 77
 	s.Running = false
78 78
 	s.Pid = 0
79
-	s.FinishedAt = time.Now()
79
+	s.FinishedAt = time.Now().UTC()
80 80
 	s.ExitCode = exitCode
81 81
 }
... ...
@@ -411,7 +411,7 @@ func (w *WriteBroadcaster) Write(p []byte) (n int, err error) {
411 411
 					w.buf.Write([]byte(line))
412 412
 					break
413 413
 				}
414
-				b, err := json.Marshal(&JSONLog{Log: line, Stream: sw.stream, Created: time.Now()})
414
+				b, err := json.Marshal(&JSONLog{Log: line, Stream: sw.stream, Created: time.Now().UTC()})
415 415
 				if err != nil {
416 416
 					// On error, evict the writer
417 417
 					delete(w.writers, sw)