Incorrectly timezoned if created with a specific value
rafaellop opened this issue · 1 comments
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.
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.