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

Google calendar: moves AllDay Events around #323

Open
albatrosify opened this issue Jul 27, 2021 · 7 comments
Open

Google calendar: moves AllDay Events around #323

albatrosify opened this issue Jul 27, 2021 · 7 comments
Labels
more information required The issue requires more information before it can be actioned

Comments

@albatrosify
Copy link

I have gotten a few bug reports, that allDay Events are starting to appear on wrong days (often 1 day earlier than correct).
I did not change anything on my code, neither did this plugin change.
It looks like my app / the plugin is inserting the events correctly, as for 10 second around the elements appear correctly for example in google calendar. After this 10seconds they start to move a day earlier...

Anyone got any similar bug reports or has any idea on how to solve this? I am not finding any issues. iOS is fine, only android in Samsung devices (and i do not own any)

@thomassth
Copy link
Contributor

Can you provide more details? Eg.

  • what version are you using? Is it still affecting the latest prerelease?
  • is it affecting local or synced calendars?
  • Since it might be a vendor-specific problem, is there any difference if you view it afterwards via Samsung calendar or Google calendar?

@thomassth thomassth added the more information required The issue requires more information before it can be actioned label Jul 28, 2021
@albatrosify
Copy link
Author

I have to correct myself. It is no longer only Samsung Devices. The bug exists across devices.
I am using the latest null-safety dev release "^4.0.1-dev.13167"
So far I only know that this issue exists on synced calendars (namely Google Calendar)

I use an iPhone and do not have any problems with sync issues. Most of my users neither have problems even on android devices.
I tried to reproduce the error on my development pixel 2 xl, as well as AVD Pixel 4 XL.
Everything was fine, UNTIL I changed the timezone in the settings of my google calendar (via web interface).
I switched it to another timezone, looked at the elements (via web interface) and then set it back to the correct time zone.

From this moment on, syncs from android to google calendar via this plugin move ONLY allday events.
Also it appears (when I look at the wrong elements afterwards from my iPhone) that the allday events spans from, for example: 17 Aug -> 16 Aug. This might explain, why the allDay Event shows a day earlier.

@thomassth
Copy link
Contributor

Sounds like the problem is about retrieval of events from calendar.

Though I wonder if this is caused by some strange approach handled by Google or bug from the package itself.

We may need to write around the bug if it's the former.

@albatrosify albatrosify changed the title Samsung Devices move AllDay Events around Google calendar: moves AllDay Events around Jul 30, 2021
@albatrosify
Copy link
Author

Is anybody able to reproduce the problem?

@FCView
Copy link
Contributor

FCView commented Jul 31, 2021

Your issue may be related to the way allDay events are stored. They should be stored from midnight utc on the first day to midnight utc on the day following the last day. For example, a 2-day allDay event on Jan 1-2 should be stored from Jan 1 00:00:00Z to Jan 3 00:00:00Z. Single-day events are currently being stored as Jan 1 00:00:00 to Jan 1 00:00:00, when the end date should be Jan 2 00:00:00. Also, I believe it is using the local timezone, not UTC. See this note about writing allDay events.

Check out my PR #324 and see if that fixes your issue.

Also, see my other comment, about problems with the way Android (or Android's CalendarContract) handles local calendars vs synced calendars. In my project, I ended up removing the ability to use local calendars for this reason.

edit: changed "Jan 2" to "Jan 3" (it should be midnight on the day after the event). Also, added more info about how single-day events are currently being stored.

@albatrosify
Copy link
Author

With your PR I was able to somehow prevent this issue with the following code:
image

Still it is really scary to insert allDay Elements into the Calendar.

@SuperKrallan
Copy link

SuperKrallan commented Jan 15, 2022

Yes, some things are not right with allDay events that span over more than one day. If you store an event that spans over 2 days, setting the allDay flag to true and the start time and end time like this (using the .toIso8601String() and print):
flutter: Start: 2022-01-14T00:00:00.000+0100
flutter: End: 2022-01-16T00:00:00.000+0100
...and save this event to the calendar, and then retrieve it again, both dates have lost their location information (so no +0100, but changed it's time with -1 h and added the "Z").
flutter: Start: 2022-01-13T23:00:00.000Z
flutter: End: 2022-01-14T22:59:59.000Z
Other non allDay events saved does not lose this information.
But you can get the location information back by using the TZDateTime.from() and add the location. Then you get...
flutter: Start: 2022-01-14T00:00:00.000+0100
flutter: End: 2022-01-14T23:59:59.000+0100
But we see here that the end time has changed from the saved 16th 00:00 to the 14th: 23:59. So instead of the exact 48h we had saved from the beginning we get back 23h 59 min 59 s...
So yes, if you are using the allDay events and save them to the calendar with start/end dates spanning over more than 24 h the end date will be changed, which in turn will be perceived as an error by the user. I think this is an error, I would like to be able to save multiple allDay events in this way, but I guess a workaround could be to make an allDay event, make sure the end date cant be set (or just hide it), and then repeat the event by setting the RecurrenceRule to the number of days you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information required The issue requires more information before it can be actioned
Projects
None yet
Development

No branches or pull requests

4 participants