Problem
The all day event sets the time to 0:01 and also does some trickery with timezones. When you save an event on a website with a timezone below GMT (e.g. America/Los_Angeles for GMT - 8) then this trickery causes the 0:01 to change to the previous day which causes an event created for 10 November 2018 to be displayed as taking place on 9 November 2018.
Solution
Drupal's time functions should take care of all the timezone things for us relative to the site and user's timezone configuration and there should be no need to touch this manually. Furthermore it might be a good idea to convert the "All day" field to a Flag module field that denotes the event as being an all day event. This would allow us to fill in any time for the hour/minutes and just ignore it on when printing. Any if statement that now checks for 0:01 would then check for the flag instead.
Attached is a patch that fixes the issue for me on Open Social 8.3.5.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | open_social--event_dates_all_day_timezone-3012005-3-d8.patch | 2.77 KB | veronicaseveryn |
| all-day-timezone-test.patch | 1.71 KB | kingdutch |
Comments
Comment #2
kingdutchPR with failing test here: https://github.com/goalgorilla/open_social/pull/1096
Comment #3
veronicaseveryn commentedI had the same issue as described.
Using "all day" option with Timezone of "New York" was displaying the date 1 day behind to the front end users + when you go back to edit the event, the date shifts also. So, if you were not paying attention to the date when re-saving the node, you could keep shifting the dates with every save of the node..
And I think I found the issue what goes wrong in this case. I have Drupal 8.6.3.
When you save "all day" event, it disables "time" form element, which causes Drupal's default handling of date/time form widgets fail in DateTimePlus::createFromFormat() with "'The date cannot be created from a format.'" exception because the Time is not passed in and the format is not correct.
I agree that Open Social shouldn't be manipulating the timezones.. and just to make the things work for now I created a patch that fixes the issue for me on Open Social 8.x-3.5
Comment #4
jaapjan commentedThanks for the patch. Created new PR here:
https://github.com/goalgorilla/open_social/pull/1141
Comment #5
jaapjan commentedAutomated testing of this PR failed. So marking as needs work, because
- Newly created Behat test is still failing
- Coding standards
Comment #7
ronaldtebrake commentedFixed as part of 3.7, thanks for the help! Will be cherry picked in all the correct branches.