ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
310 stars 107 forks source link

Support non-standard time format #177

Closed joec4i closed 1 year ago

joec4i commented 1 year ago

We are working with a Swift backend server that returns last_modified formatted as 2022-08-18T04:02:34Z instead of 2022-08-18T04:02:34 . Because of that, the Objects() call returns the following error:

parsing time "2022-08-18T04:02:34Z": extra text: "Z"

As per the OpenStack Storage API reference,

The date and time stamp format is ISO 8601:

2022-08-18T04:02:34Z appears to be a valid ISO 8601 format according to wikipedia.

The easiest way to support it is probably to make time format a setting that can be changed by the user. This PR does that.

This removes the Z suffix from object.ServerLastModified before using it.

Please review.

Thanks!

ncw commented 1 year ago

I would be included just to remove a trailing Z if it exists - then the code will adapt to either format with no configuration.

joec4i commented 1 year ago

I would be included just to remove a trailing Z if it exists - then the code will adapt to either format with no configuration.

Hmm yeah that's better. Thanks @ncw . It's updated now. Please have another look. Note: I didn't add a new test case because it's too much trouble to make the test server return time with a trailing Z. The existing test TestObjects() should still pass though.

joec4i commented 1 year ago

Hi @ncw Any chance we can get this in? 🙏 🙏

ncw commented 1 year ago

Thank you :-)