Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: Restore local event time #1185

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Conversation

iandunn
Copy link
Member

@iandunn iandunn commented Dec 19, 2023

Fixes #1170

This changes back to displaying the event date/times in JS, so they can be converted to the visitor's local time instead of being in UTC.

@iandunn iandunn added this to the Events: Promotion milestone Dec 19, 2023
@iandunn iandunn self-assigned this Dec 19, 2023
@iandunn iandunn force-pushed the restore-local-event-time branch 4 times, most recently from 9b57b55 to 38501c3 Compare December 21, 2023 00:31
@iandunn
Copy link
Member Author

iandunn commented Dec 21, 2023

This is mostly working, just needs some clean up. The one big problem left is that the block fails to render in the template editor. I think it's a similar problem to WordPress/wporg-mu-plugins#500

It's a dynamic block, and the PHP render() passes some data to JS via wp_add_inline_script(). That works well on the front end, but in the editor the JS variable is undefined. Edit() uses <ServerSideRender>.

I guess the "correct" way to do it would be to fork view.js into edit.js as a React component, but it doesn't seem like that should be necessary. It'd waste time and introduce tech debt.

@renintw @adamwoodnz @StevenDufresne, do you have any thoughts on a way to reuse view.js in the template editor, or is the only way to fork it?

@iandunn iandunn force-pushed the restore-local-event-time branch from 38501c3 to eb27fae Compare December 21, 2023 19:26
@iandunn iandunn force-pushed the restore-local-event-time branch from eb27fae to 813cc81 Compare December 21, 2023 19:32
This moves date rendering back to JavaScript, and posts the grouping there as well. That's necessary because the month boundaries are affected by the user's timezone.
@iandunn iandunn force-pushed the restore-local-event-time branch from 813cc81 to 5d3e6a1 Compare December 21, 2023 19:45
@iandunn iandunn marked this pull request as ready for review December 21, 2023 19:53
@iandunn iandunn merged commit 9d652d2 into production Dec 21, 2023
@iandunn iandunn deleted the restore-local-event-time branch December 21, 2023 19:53
@iandunn
Copy link
Member Author

iandunn commented Dec 21, 2023

I removed view.js from editorScript since it wasn't working, and added an early return if the global isn't defined. That avoids the explicit error in the editor, but doesn't fix the underlying problem. We can fix that in a future PR if any of you have ideas on that, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Events: Replace UTC time with local time.
1 participant