From 066d411367905cce8a47f9de94a4be9baba7ba37 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Wed, 20 Aug 2025 22:54:51 +1000 Subject: [PATCH] chore: parse Created time on container with CreatedTime --- pkg/api/container.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/api/container.go b/pkg/api/container.go index 40a585a8..9452644e 100644 --- a/pkg/api/container.go +++ b/pkg/api/container.go @@ -24,6 +24,20 @@ const ( type Container struct { types.ContainerJSON + // created caches the parsed creation time by CreatedTime. + created time.Time +} + +// CreatedTime returns the time when the container was created parsed from the Created field. +func (c *Container) CreatedTime() time.Time { + if c.created.IsZero() { + created, err := time.Parse(time.RFC3339Nano, c.Created) + if err != nil { + return time.Time{} + } + c.created = created + } + return c.created } // Healthy determines if the container is running and healthy.