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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JKingsnorth’s picture

Priority: Normal » Major
Issue summary: View changes

Updating 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.

JKingsnorth’s picture

Issue summary: View changes

Updating the issue with clearer instructions to recreate the problems.

JKingsnorth’s picture

Issue summary: View changes
JKingsnorth’s picture

Status: Active » Needs review
FileSize
1.77 KB

This 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.

JKingsnorth’s picture

JKingsnorth’s picture

Title: Event time display (timezone handling and cache flushing) » Event page time display incorrect (timezone handling)
Version: 7.x-2.13 » 7.x-2.21
Issue summary: View changes
FileSize
398.38 KB

It 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,

JKingsnorth’s picture

Issue summary: View changes
Status: Needs review » Needs work

Updated 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.

JKingsnorth’s picture

Issue summary: View changes
JKingsnorth’s picture

Assigned: Unassigned » JKingsnorth

Working on a patch

JKingsnorth’s picture

Status: Needs work » Needs review
FileSize
2.5 KB

Right 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

JKingsnorth’s picture

Assigned: JKingsnorth » Unassigned
mpotter’s picture

Status: Needs review » Fixed

Yep, I believe the logic of this patch is correct. I merged the pull request. Thanks for catching this and patching it!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.