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

Incorrectly timezoned if created with a specific value #148

Open
rafaellop opened this issue Nov 21, 2022 · 1 comment
Open

Incorrectly timezoned if created with a specific value #148

rafaellop opened this issue Nov 21, 2022 · 1 comment

Comments

@rafaellop
Copy link

The hour is incorrectly timezoned if a date is instantiated by now() or by a value. For example I have this function:

  tz.TZDateTime _nextInstanceOfHour({required int hour}) {
    final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
    tz.TZDateTime scheduledDate = tz.TZDateTime(tz.local, now.year, now.month, now.day, hour);
   ...
}

The now variable is correctly set according to my timezone while it seems that the second variable called scheduledDate doesn't consider the tz.local at all. Example with some numbers:

For the local time of e.g. 2022-11-21 10:59 the now variable is set to 2022-11-21 9:59
However the scheduledDate with the hour parameter set to e.g. 11 is just left as 2022-11-21 11:00 when it should be 2022-11-21 10:00.

I'm on GMT+01:00.

@rafaellop
Copy link
Author

Additional info:

The timezone is initialized like this:

tz.initializeTimeZones();

but if I add additional initialization code:

final String timeZoneName = await FlutterNativeTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(timeZoneName));

Then both dates in the above example are the same, but not properly 1 hour shifted. I mean the first date is assigned to the now variable is not 2022-11-21 10:59 and the second remains the same 2022-11-21 10:00. In the effect if I use these datetimes in a local notification setup it is fired an hour later than expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant