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

TimeZone problems #34

Open
mclwill opened this issue Feb 13, 2024 · 7 comments
Open

TimeZone problems #34

mclwill opened this issue Feb 13, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@mclwill
Copy link

mclwill commented Feb 13, 2024

The full calendar is displaying events with a delay of 11 hours from the time recorded for the event in Civi - clearly it is thinking the times are UTC. However when I download a calendar of events from Civi - ie an ical.ics all of the timezone information for the events is correct (ie. set for GMT + 11 hours for Melbourne Australia). Not sure what has to be done to get full_calendar displaying in the correct timezone

@agileware-justin
Copy link
Contributor

@mclwill that is interesting, especially since when we last worked on the Events Calendar it was for a customer in Melbourne, Australia.

Is your calendar URL public? Would be good to check it out. If not, that's OK. I would do a basic check of making sure that WordPress is timezone is set to Melbourne/Australia and not GMT+11.

@agileware-justin agileware-justin added the question Further information is requested label Feb 13, 2024
@mclwill
Copy link
Author

mclwill commented Feb 13, 2024

WP timezone is set to Melbourne/Australia.

I have just made the URL public for you to have a look : https://zoedaniel.com.au/civicrm-events-calendar/

@agileware-justin
Copy link
Contributor

Thanks @mclwill that does look a bit odd. I don't have an immediate answer, we will need to review and see what may be causing that issue. Might take a week or two to get back to this one.

@mclwill
Copy link
Author

mclwill commented Feb 14, 2024

Thanks for taking a look. I will need to make that URL private again.

If you could let me know I will make public again when you are checking.

@mclwill
Copy link
Author

mclwill commented Feb 14, 2024

I've done some trial and error changes - this plugin seems to fix the problem.
https://wordpress.org/plugins/use-clients-time-zone/

But would be good to know why it is needed.
Thanks again for your help.

@mclwill
Copy link
Author

mclwill commented Feb 14, 2024

I've had to remove that plugin at it causes some other WP event plugins to display the wrong time zone.

So back to square one.

Any help would be appreciated.

@mclwill
Copy link
Author

mclwill commented Feb 18, 2024

I think I have located the problem I am having:

The code in rest/json-all-events.php is not formatting the start and end time of events in line with the FullCalendar requirements. Timezone offsets need to have a colon between hour and minutes (see https://fullcalendar.io/docs/timeZone) in line with ISO8601.

But for some strange reason PHP function date_format needs parameter DATE_ATOM (and not DATE_ISO8601) to achieve the correct format for ISO8601 - see https://www.php.net/manual/en/class.datetimeinterface.php#datetimeinterface.constants.types

Need to change this in four places of get_all_events in rest/json-all-events.php and also do an extra call to wp_timezone() in else statement of get wordpress timezone

when I change the date formatting as per the following I am getting the correct resuls :

'start' => (new DateTimeImmutable($event['start_date'], $tz))->format(DateTime::ATOM),

@agileware-justin agileware-justin added bug Something isn't working and removed question Further information is requested labels Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants