syncfusion/flutter-examples

[SfCalendar] Weird behaviour with all timezones UTC

jonasbadstuebner opened this issue · 2 comments

Hey there,
I wanted to implement my calendar and all its appointments in UTC to make time shifting in my backend easier.
Unfortunately, if I set

SfCalendar(
  [...]
  timeZone: 'UTC',
  [...]
)

and on the appointments/datasource

  @override
  String? getStartTimeZone(int index) => 'UTC';

  @override
  String? getEndTimeZone(int index) => 'UTC';

I get a start time where appointment.startTime.timeZoneName == 'CET' and appointment.startTimeZone == 'UTC'

Could someone look into this and track my error down please? Or tell me a workaround?
I tried to find the error in the code of SfCalendar, but it is huge and I thought someone with more experience with this library could help me.
Thank you in advance!

Maybe it is helpful to know the following:
I set

@override
DateTime getStartTime(int index) {
  return DateTime.fromMillisecondsSinceEpoch(1700000000000, isUtc: true);
}
SfCalendar(
  [...]
  timeZone: 'UTC',
  [...]
)

with

  @override
  String? getStartTimeZone(int index) => 'Australia/Perth';

  @override
  String? getEndTimeZone(int index) => 'Australia/Perth';

(Australia/Perth is just a random test with big time shift to see an effect)
This gives
appointment.startTime.timeZoneName == CET appointment.startTime == 2023-11-14 14:13:20.000 appointment.startTimeZone == Australia/Perth
appoinment.startTime is shifted by 8 hours into the past - which is correct (I think).


SfCalendar(
  [...]
  timeZone: 'Australia/Perth',
  [...]
)

with

  @override
  String? getStartTimeZone(int index) => 'UTC';

  @override
  String? getEndTimeZone(int index) => 'UTC';

gives
appointment.startTime.timeZoneName == CET appointment.startTime == 2023-11-14 07:13:20.000 appointment.startTimeZone == UTC
the time is shifted 16 hours into the past. Which is not correct, I think.


SfCalendar(
  [...]
  // timeZone: 'nothing set',
  [...]
)

with

  @override
  String? getStartTimeZone(int index) => 'UTC';

  @override
  String? getEndTimeZone(int index) => 'UTC';

gives me
appointment.startTime.timeZoneName == CET appointment.startTime == 2023-11-14 15:13:20.000 appointment.startTimeZone == Australia/Perth


Timezone shifting is a hard topic imho...so I am grateful if someone has an idea and I would be happy to test it out.

Well I guess I should open it in flutter-widget instead