Closed samueleaton closed 5 years ago
S3 and DigitalOcean spaces both seem to use ISO string where the date and time are separated by a T
.
I could parse the times so @last_modifed
is a Time
instead of a String
.
I'm just not aware of any edge cases, like if times are ever stored without milliseconds, or if they are always in UTC time.
Thanks! I think parsing it as a Time
would be solid. Doing that in other places like https://github.com/taylorfinnell/awscr-s3/blob/master/src/awscr-s3/responses/list_all_my_buckets.cr#L23 albeit it needs to be fixed there :)
I tried to use the existing Time Format string you showed me above but the time returned by DigitalOcean uses a decimal precision (e.g. 2019-03-06T01:52:47.037Z
) so it breaks when it sees the period. Should we do it without decimal precision or a timezone and just parse it as UTC?
Example:
# "%Y-%M-%dT%H:%M:%S" is the same as "%FT%T"
last_modified = Time.parse(object.string("LastModified"), "%FT%T", Time::Location::UTC)
(When you don't specify a timezone in the time format string it required a location)
It looks like if a timestamp format is not specified the Ruby gem parses UTC and iso 8601. So I guess let's do that
exposes the LastModifed time string to the user
example: