Problem
When viewing an event node the date and time are not displayed in the user's timezone. This is not consistent with the rest of the site as the attached screenshot shows.
This is because the custom OA date formatter 'Next Upcoming Date' (oa_events_upcoming_date) does not take timezone handling into account correctly when generating the display:
https://github.com/phase2/oa_events/blob/21901f57e8888ccc4b76698f6146932...
(The original issue also references this problem with the date module: #2206407: User's timezone should not be cached in field)
Steps to recreate
On a fresh install. Create an admin with one timezone and a user with another. As the admin, create an event in a new public calendar section. View it in the calendar as the user, and the time displays correctly (also in the sidebar). View the event node and the time displays in the original timezone instead. (As per the attached screenshot).
Recommended action
Patch oa_events.module so that the custom formatter correctly translates the dates into the current user's timezone.
Comment | File | Size | Author |
---|---|---|---|
#10 | oa_events-2205451-12.patch | 2.5 KB | JKingsnorth |
#6 | timezone-display-issue.jpg | 398.38 KB | JKingsnorth |
Comments
Comment #1
JKingsnorth CreditAttribution: JKingsnorth commentedUpdating this to a major issue since it affects the time displayed for all events in the system. See the issue summary for updated instructions to recreate the issue.
Comment #2
JKingsnorth CreditAttribution: JKingsnorth commentedUpdating the issue with clearer instructions to recreate the problems.
Comment #3
JKingsnorth CreditAttribution: JKingsnorth commentedComment #4
JKingsnorth CreditAttribution: JKingsnorth commentedThis patch changes the custom date formatter to use the current user's timezone when formatting the date, rather than the timezone associated with the node. The timezone associated with the node isn't useful to us, since it is the timezone of the user who created the node.
Comment #5
JKingsnorth CreditAttribution: JKingsnorth commentedFollow-up issue created: #2206407: User's timezone should not be cached in field
Comment #6
JKingsnorth CreditAttribution: JKingsnorth commentedIt would be great if we could get a review of the patch in #4 - this is still an issue in the latest version. See #2331965: Event date and time display - timezone incorrect. Screenshot of the issue attached,
Comment #7
JKingsnorth CreditAttribution: JKingsnorth commentedUpdated issue summary.
The patch in #4 is not suitable because the module goes on to use those variables to build the 'add to calendar' link. This link is hardcoded to the UTC timezone.
Comment #8
JKingsnorth CreditAttribution: JKingsnorth commentedComment #9
JKingsnorth CreditAttribution: JKingsnorth commentedWorking on a patch
Comment #10
JKingsnorth CreditAttribution: JKingsnorth commentedRight I've put together a patch that appears to fix the issue, converting the date/time to the user's timezone using the same method as the formatters in date.module.
I hope this was the right approach, I'm only just starting to familiarise myself with the way the date api works.
PR here: https://github.com/phase2/oa_events/pull/12
Patch: https://github.com/phase2/oa_events/pull/12.patch
Comment #11
JKingsnorth CreditAttribution: JKingsnorth commentedComment #12
mpotter CreditAttribution: mpotter commentedYep, I believe the logic of this patch is correct. I merged the pull request. Thanks for catching this and patching it!