Fix timezone issues in #attribute_to_time/#to_iso8601_date #961
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
#attribute_to_time
convertDate
to UTC (rather than local)Time
#to_iso8601_date
return UTC representationDetailed description
#to_iso8601_date
currently deliberately does not convert to UTC, because the date is supposed to be timezone-agnostic.For example, if I were to write
2016-10-22
, then I intend that specific day, no matter where I am, and what time it is. Converting this date to UTC first could change that date to2016-10-21
or2016-10-23
, which is not what’s intended.Unfortunately, this does not hold up when I write a
Time
(e.g.2016-10-22 10:15:00
) rather than aDate
and then run it through#to_iso8601_date
.In order to make both cases work, this PR converts
Date
to UTCTime
s rather than localTime
s, and then makes#to_iso8601_date
convert to UTC.This PR also uncovered an interesting case in the XML sitemap helper (arguably a bug), which is now also fixed.
See also