我正在使用颤振本地通知进行调度,因为我正在使用时区调度。 问题是 Timezone 对象返回国家、月份、日期和分钟,但延迟一小时。所以当我需要在上午 10 点安排通知时,由于延迟,它会在明天上午 9 点发生。是否有时区库返回更准确的时区? 代码是:
tz.TZDateTime _nextInstanceOfTenAM({required int hour, required int minute}) {
final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
tz.TZDateTime scheduledDate =
tz.TZDateTime(tz.local, now.year, now.month, now.day, 10, 50);
if (scheduledDate.isBefore(now)) {
scheduledDate = scheduledDate.add(const Duration(days: 1));
}
return scheduledDate;
}