From 414ccaaff09269ee5b846780a0b5513ba3faeaac Mon Sep 17 00:00:00 2001 From: Joe Cai Date: Mon, 19 Sep 2022 15:00:18 +1000 Subject: [PATCH] Support time format with the Z suffix --- swift.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/swift.go b/swift.go index c9357ee3f..062a1f35f 100644 --- a/swift.go +++ b/swift.go @@ -1114,16 +1114,13 @@ func (c *Connection) Objects(ctx context.Context, container string, opts *Object object.ContentType = "application/directory" } if object.ServerLastModified != "" { - // 2012-11-11T14:49:47.887250 + // e.g. 2012-11-11T14:49:47, 2012-11-11T14:49:47Z, 2012-11-11T14:49:47.887250, or 2012-11-11T14:49:47.887250Z + // Remove the Z suffix and fractional seconds if present. This then keeps it consistent with Object which + // can only return timestamps accurate to 1 second // - // Remove fractional seconds if present. This - // then keeps it consistent with Object - // which can only return timestamps accurate - // to 1 second - // - // The TimeFormat will parse fractional - // seconds if desired though - datetime := strings.SplitN(object.ServerLastModified, ".", 2)[0] + // The TimeFormat will parse fractional seconds if desired though + lastModified := strings.TrimSuffix(object.ServerLastModified, "Z") + datetime := strings.SplitN(lastModified, ".", 2)[0] object.LastModified, err = time.Parse(TimeFormat, datetime) if err != nil { return nil, err