Skip to content

Commit b261ce5

Browse files
committed
Revert "Fix inconsistent date formats in API"
This reverts commit 945fc9d. Signed-off-by: Victor Vieux <victorvieux@gmail.com>
1 parent e4855ee commit b261ce5

File tree

10 files changed

+22
-135
lines changed

10 files changed

+22
-135
lines changed

api/client/history.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
4747
}
4848
if !*quiet {
4949
if *human {
50-
fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(entry.Created)))
50+
fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0))))
5151
} else {
52-
fmt.Fprintf(w, "\t%s\t", entry.Created.Format(time.RFC3339))
52+
fmt.Fprintf(w, "\t%s\t", time.Unix(entry.Created, 0).Format(time.RFC3339))
5353
}
5454

5555
if *noTrunc {

api/client/images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ func (cli *DockerCli) CmdImages(args ...string) error {
109109

110110
if !*quiet {
111111
if *showDigests {
112-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", repo, tag, digest, ID, units.HumanDuration(time.Now().UTC().Sub(image.Created)), units.HumanSize(float64(image.VirtualSize)))
112+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", repo, tag, digest, ID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(image.Created), 0))), units.HumanSize(float64(image.VirtualSize)))
113113
} else {
114-
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, ID, units.HumanDuration(time.Now().UTC().Sub(image.Created)), units.HumanSize(float64(image.VirtualSize)))
114+
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, ID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(image.Created), 0))), units.HumanSize(float64(image.VirtualSize)))
115115
}
116116
} else {
117117
fmt.Fprintln(w, ID)

api/client/ps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (cli *DockerCli) CmdPs(args ...string) error {
151151
}
152152

153153
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", ID, image, command,
154-
units.HumanDuration(time.Now().UTC().Sub(container.Created)),
154+
units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(container.Created), 0))),
155155
container.Status, api.DisplayablePorts(container.Ports), strings.Join(names, ","))
156156

157157
if *size {

api/server/server.go

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -353,37 +353,6 @@ func (s *Server) getImagesJSON(version version.Version, w http.ResponseWriter, r
353353
return err
354354
}
355355

356-
// For version >= 1.19 the Created filed of image will change
357-
// from int64 to time.Time.
358-
// This is for legacy data format.
359-
if version.LessThan("1.19") {
360-
type legacyImage struct {
361-
ID string `json:"Id"`
362-
ParentId string
363-
RepoTags []string
364-
RepoDigests []string
365-
Created int64
366-
Size int
367-
VirtualSize int
368-
Labels map[string]string
369-
}
370-
371-
legacy := []*legacyImage{}
372-
for _, img := range images {
373-
l := &legacyImage{
374-
ID: img.ID,
375-
ParentId: img.ParentId,
376-
RepoTags: img.RepoTags,
377-
RepoDigests: img.RepoDigests,
378-
Created: img.Created.Unix(),
379-
Size: img.Size,
380-
VirtualSize: img.VirtualSize,
381-
Labels: img.Labels,
382-
}
383-
legacy = append(legacy, l)
384-
}
385-
return writeJSON(w, http.StatusOK, legacy)
386-
}
387356
return writeJSON(w, http.StatusOK, images)
388357
}
389358

@@ -513,34 +482,6 @@ func (s *Server) getImagesHistory(version version.Version, w http.ResponseWriter
513482
return err
514483
}
515484

516-
// For version >= 1.19 the Created filed of image will change
517-
// from int64 to time.Time.
518-
// This is for legacy data format.
519-
if version.LessThan("1.19") {
520-
type legacyImageHistory struct {
521-
ID string `json:"Id"`
522-
Created int64
523-
CreatedBy string
524-
Tags []string
525-
Size int64
526-
Comment string
527-
}
528-
529-
legacy := []*legacyImageHistory{}
530-
for _, img := range history {
531-
l := &legacyImageHistory{
532-
ID: img.ID,
533-
Created: img.Created.Unix(),
534-
CreatedBy: img.CreatedBy,
535-
Tags: img.Tags,
536-
Size: img.Size,
537-
Comment: img.Comment,
538-
}
539-
legacy = append(legacy, l)
540-
}
541-
return writeJSON(w, http.StatusOK, legacy)
542-
}
543-
544485
return writeJSON(w, http.StatusOK, history)
545486
}
546487

@@ -600,42 +541,6 @@ func (s *Server) getContainersJSON(version version.Version, w http.ResponseWrite
600541
return err
601542
}
602543

603-
// For version >= 1.19 the Created filed of container will change
604-
// from int64 to time.Time.
605-
// This is for legacy data format.
606-
if version.LessThan("1.19") {
607-
type legacyContainer struct {
608-
ID string `json:"Id"`
609-
Names []string `json:",omitempty"`
610-
Image string `json:",omitempty"`
611-
Command string `json:",omitempty"`
612-
Created int64 `json:",omitempty"`
613-
Ports []types.Port `json:",omitempty"`
614-
SizeRw int `json:",omitempty"`
615-
SizeRootFs int `json:",omitempty"`
616-
Labels map[string]string `json:",omitempty"`
617-
Status string `json:",omitempty"`
618-
}
619-
620-
legacyContainers := []*legacyContainer{}
621-
for _, c := range containers {
622-
lc := &legacyContainer{
623-
ID: c.ID,
624-
Names: c.Names,
625-
Image: c.Image,
626-
Command: c.Command,
627-
Created: c.Created.Unix(),
628-
Ports: c.Ports,
629-
SizeRw: c.SizeRw,
630-
SizeRootFs: c.SizeRootFs,
631-
Labels: c.Labels,
632-
Status: c.Status,
633-
}
634-
legacyContainers = append(legacyContainers, lc)
635-
}
636-
return writeJSON(w, http.StatusOK, legacyContainers)
637-
}
638-
639544
return writeJSON(w, http.StatusOK, containers)
640545
}
641546

api/types/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type ContainerChange struct {
5050
// GET "/images/{name:.*}/history"
5151
type ImageHistory struct {
5252
ID string `json:"Id"`
53-
Created time.Time
53+
Created int64
5454
CreatedBy string
5555
Tags []string
5656
Size int64
@@ -69,7 +69,7 @@ type Image struct {
6969
ParentId string
7070
RepoTags []string
7171
RepoDigests []string
72-
Created time.Time
72+
Created int
7373
Size int
7474
VirtualSize int
7575
Labels map[string]string
@@ -105,7 +105,7 @@ type Container struct {
105105
Names []string `json:",omitempty"`
106106
Image string `json:",omitempty"`
107107
Command string `json:",omitempty"`
108-
Created time.Time `json:",omitempty"`
108+
Created int `json:",omitempty"`
109109
Ports []Port `json:",omitempty"`
110110
SizeRw int `json:",omitempty"`
111111
SizeRootFs int `json:",omitempty"`

daemon/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (daemon *Daemon) Containers(config *ContainersConfig) ([]*types.Container,
149149
} else {
150150
newC.Command = fmt.Sprintf("%s", container.Path)
151151
}
152-
newC.Created = container.Created.UTC()
152+
newC.Created = int(container.Created.Unix())
153153
newC.Status = container.State.String()
154154

155155
newC.Ports = []types.Port{}

docs/sources/reference/api/docker_remote_api.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,6 @@ disconnect
5858

5959
This endpoint now accepts a `since` timestamp parameter.
6060

61-
`GET /images/json`
62-
63-
**New!**
64-
The `Created` field is now formatted as a RFC3339 string instead of a UNIX
65-
timestamp, to be consistent with other parts of the API.
66-
67-
`GET /containers/json`
68-
69-
**New!**
70-
The `Created` field is now formatted as a RFC3339 string instead of a UNIX
71-
timestamp, to be consistent with other parts of the API.
72-
73-
`GET /images/(name)/history`
74-
75-
**New!**
76-
The `Created` field is now formatted as a RFC3339 string instead of a UNIX
77-
timestamp, to be consistent with other parts of the API.
78-
7961
## v1.18
8062

8163
### Full documentation

docs/sources/reference/api/docker_remote_api_v1.19.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ List containers
3838
"Id": "8dfafdbc3a40",
3939
"Image": "ubuntu:latest",
4040
"Command": "echo 1",
41-
"Created": "2015-03-28T08:19:30.820225442Z",
41+
"Created": 1367854155,
4242
"Status": "Exit 0",
4343
"Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
4444
"SizeRw": 12288,
@@ -48,7 +48,7 @@ List containers
4848
"Id": "9cd87474be90",
4949
"Image": "ubuntu:latest",
5050
"Command": "echo 222222",
51-
"Created": "2015-01-05T19:42:44.334772611Z",
51+
"Created": 1367854155,
5252
"Status": "Exit 0",
5353
"Ports": [],
5454
"SizeRw": 12288,
@@ -58,7 +58,7 @@ List containers
5858
"Id": "3176a2479c92",
5959
"Image": "ubuntu:latest",
6060
"Command": "echo 3333333333333333",
61-
"Created": "2014-11-26T20:35:41.514880809Z",
61+
"Created": 1367854154,
6262
"Status": "Exit 0",
6363
"Ports":[],
6464
"SizeRw":12288,
@@ -68,7 +68,7 @@ List containers
6868
"Id": "4cb07b47f9fb",
6969
"Image": "ubuntu:latest",
7070
"Command": "echo 444444444444444444444444444444444",
71-
"Created": "2014-11-26T15:35:05.538305907Z",
71+
"Created": 1367854152,
7272
"Status": "Exit 0",
7373
"Ports": [],
7474
"SizeRw": 12288,
@@ -1148,7 +1148,7 @@ Status Codes:
11481148
"ubuntu:latest"
11491149
],
11501150
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
1151-
"Created": "2014-11-26T15:35:05.538305907Z",
1151+
"Created": 1365714795,
11521152
"Size": 131506275,
11531153
"VirtualSize": 131506275
11541154
},
@@ -1159,7 +1159,7 @@ Status Codes:
11591159
],
11601160
"ParentId": "27cf784147099545",
11611161
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
1162-
"Created": "2014-11-21T10:18:46.654545839Z",
1162+
"Created": 1364102658,
11631163
"Size": 24653,
11641164
"VirtualSize": 180116135
11651165
}
@@ -1176,7 +1176,7 @@ Status Codes:
11761176

11771177
[
11781178
{
1179-
"Created": "2015-03-23T15:58:07.610802612Z",
1179+
"Created": 1420064636,
11801180
"Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
11811181
"ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
11821182
"RepoDigests": [
@@ -1392,12 +1392,12 @@ Return the history of the image `name`
13921392
[
13931393
{
13941394
"Id": "b750fe79269d",
1395-
"Created": "2014-12-15T19:52:48.480875289Z",
1395+
"Created": 1364102658,
13961396
"CreatedBy": "/bin/bash"
13971397
},
13981398
{
13991399
"Id": "27cf78414709",
1400-
"Created": "2013-06-13T21:03:50.821769Z",
1400+
"Created": 1364068391,
14011401
"CreatedBy": ""
14021402
}
14031403
]

graph/history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s *TagStore) History(name string) ([]*types.ImageHistory, error) {
3030
err = foundImage.WalkHistory(func(img *image.Image) error {
3131
history = append(history, &types.ImageHistory{
3232
ID: img.ID,
33-
Created: img.Created.UTC(),
33+
Created: img.Created.Unix(),
3434
CreatedBy: strings.Join(img.ContainerConfig.Cmd.Slice(), " "),
3535
Tags: lookupMap[img.ID],
3636
Size: img.Size,

graph/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type ByCreated []*types.Image
2828

2929
func (r ByCreated) Len() int { return len(r) }
3030
func (r ByCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
31-
func (r ByCreated) Less(i, j int) bool { return r[i].Created.Before(r[j].Created) }
31+
func (r ByCreated) Less(i, j int) bool { return r[i].Created < r[j].Created }
3232

3333
func (s *TagStore) Images(config *ImagesConfig) ([]*types.Image, error) {
3434
var (
@@ -101,7 +101,7 @@ func (s *TagStore) Images(config *ImagesConfig) ([]*types.Image, error) {
101101
newImage := new(types.Image)
102102
newImage.ParentId = image.Parent
103103
newImage.ID = image.ID
104-
newImage.Created = image.Created.UTC()
104+
newImage.Created = int(image.Created.Unix())
105105
newImage.Size = int(image.Size)
106106
newImage.VirtualSize = int(image.GetParentsSize(0) + image.Size)
107107
newImage.Labels = image.ContainerConfig.Labels
@@ -138,7 +138,7 @@ func (s *TagStore) Images(config *ImagesConfig) ([]*types.Image, error) {
138138
newImage.RepoTags = []string{"<none>:<none>"}
139139
newImage.RepoDigests = []string{"<none>@<none>"}
140140
newImage.ID = image.ID
141-
newImage.Created = image.Created.UTC()
141+
newImage.Created = int(image.Created.Unix())
142142
newImage.Size = int(image.Size)
143143
newImage.VirtualSize = int(image.GetParentsSize(0) + image.Size)
144144
newImage.Labels = image.ContainerConfig.Labels

0 commit comments

Comments
 (0)