Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-standard time format #177

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down