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 inconsistency between iOS and Android #559

Open
hamishjohnson opened this issue Sep 13, 2024 · 0 comments
Open

Timezone inconsistency between iOS and Android #559

hamishjohnson opened this issue Sep 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hamishjohnson
Copy link

hamishjohnson commented Sep 13, 2024

Describe the bug
On Android, all day events are returned as a timezone agnostic date, but represented as UTC.
On iOS, all day events are returned as timezone aware date

That is to say, on android if you create an all day event on 13 Sep - the raw date will be 13 Sep 12 AM UTC in every timezone that you set your device.

Android:

I/flutter (12329): device timezone: Asia/Bangkok
I/flutter (12329): chosen timezone: America/Los_Angeles
I/flutter (12329): raw date: 2024-09-13 00:00:00.000+0000
I/flutter (12329): zoned date : 2024-09-12 17:00:00.000-0700
I/flutter (17680): zoned date to utc: 2024-09-13 00:00:00.000Z
I/flutter (12329): device timezone: America/Los_Angeles
I/flutter (12329): chosen timezone: America/Los_Angeles
I/flutter (12329): raw date: 2024-09-13 00:00:00.000+0000
I/flutter (12329): zoned date : 2024-09-12 17:00:00.000-0700
I/flutter (17680): zoned date to utc: 2024-09-13 00:00:00.000Z

On iOS however, if you create an all day event on 13th Sep - the date changes depending on your device location

iOS:

flutter: device timezone: Asia/Bangkok
flutter: chosen timezone: America/Los_Angeles
flutter: raw date: 2024-09-12 17:00:00.000Z
flutter: zoned date : 2024-09-12 10:00:00.000-0700
flutter: zoned date to utc: 2024-09-12 17:00:00.000Z
flutter: device timezone: America/Los_Angeles
flutter: chosen timezone: America/Los_Angeles
flutter: raw date: 2024-09-13 07:00:00.000Z
flutter: zoned date : 2024-09-13 00:00:00.000-0700
flutter: zoned date to utc: 2024-09-13 07:00:00.000Z

Using this code for testing:

final date = TZDateTime.from(event.start!, getLocation(timezone));

if (event.allDay == true) {
  FlutterTimezone.getLocalTimezone().then((deviceTimezone) {
    print('device timezone: $deviceTimezone');
    print('chosen timezone: $timezone');
    print('raw date: ${event.start!}');
    print('zoned date : $date');
    print('zoned date to utc: ${date.toUtc()}');
  });
}

Expected behavior
Dates should be consistent.

I think that the android result is the wrong one, since it's representing midnight UTC no matter where your device is (If you are in Los Angeles, it doesn't make sense if the date is set to 13 Sep 12 UTC, because that represents a point in time that it is not)

However, it's worth noting that these are both inconsistent with how google calendar all day events work. Gcal all day events have no timezone associated with them. So they are just a date string: 2024-09-13 and should be treated as local dates

Device(s) tested
Android Emulator & iOS Emulator

@hamishjohnson hamishjohnson added the bug Something isn't working label Sep 13, 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
Projects
None yet
Development

No branches or pull requests

1 participant