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.

Comments

Kingdutch created an issue. See original summary.

kingdutch’s picture

veronicaseveryn’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.77 KB

I 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

jaapjan’s picture

Thanks for the patch. Created new PR here:
https://github.com/goalgorilla/open_social/pull/1141

jaapjan’s picture

Status: Needs review » Needs work

Automated testing of this PR failed. So marking as needs work, because

- Newly created Behat test is still failing
- Coding standards


FILE: .../social/modules/social_features/social_event/social_event.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 432 | ERROR | [x] A cast statement must be followed by a single
     |       |     space
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

  • Kingdutch committed 016fed5 on 8.x-3.x
    Issue #3012005 by Kingdutch: Creating an all day event on GMT - X...
  • ronaldtebrake committed 1e292b3 on 8.x-3.x
    #3012005 by ronaldtebrake: Update coding standards fix + behat test
    
  • ronaldtebrake authored 31c004d on 8.x-3.x
    Merge pull request #1141 from goalgorilla/bugfix/3012005-all-day-event-...
  • jaapjan committed 90b30c2 on 8.x-3.x authored by veronicaSeveryn
    Issue #3012005 by Kingdutch, veronicaSeveryn: Creating an all day event...
ronaldtebrake’s picture

Status: Needs work » Fixed

Fixed as part of 3.7, thanks for the help! Will be cherry picked in all the correct branches.

Status: Fixed » Closed (fixed)

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